Module: HTTPX::Chainable
Overview
Session mixin, implements most of the APIs that the users call. delegates to a default session when extended.
Instance Method Summary collapse
- #accept(type) ⇒ Session
-
#branch(options) {|arg0| ... } ⇒ Object
returns a default instance of HTTPX::Session.
-
#default_options ⇒ Options
returns default instance of HTTPX::Options.
-
#plugin(pl, options = nil) {|arg0| ... } ⇒ Object
returns a new instance loaded with the
plplugin andoptions. -
#request(*args, **options) ⇒ Object
delegates to the default session (see HTTPX::Session#request).
-
#with(options) {|arg0| ... } ⇒ Object
returns a new instance loaded with
options. -
#wrap {|arg0| ... } ⇒ void
delegates to the default session (see HTTPX::Session#wrap).
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, **options, &blk) ⇒ Object (private)
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/httpx/chainable.rb', line 56 def method_missing(meth, *args, **, &blk) case meth when /\Awith_(.+)/ option = Regexp.last_match(1) return super unless option with(option.to_sym => args.first || ) when /\Aon_(.+)/ callback = Regexp.last_match(1) return super unless %w[ connection_opened connection_closed request_error request_started request_body_chunk request_completed response_started response_body_chunk response_completed ].include?(callback) warn "DEPRECATION WARNING: calling `.#{meth}` on plain HTTPX sessions is deprecated. " \ "Use `HTTPX.plugin(:callbacks).#{meth}` instead." plugin(:callbacks).__send__(meth, *args, **, &blk) else super end end |
Instance Method Details
#accept(type) ⇒ Session
20 21 22 |
# File 'lib/httpx/chainable.rb', line 20 def accept(type) with(headers: { "accept" => String(type) }) end |
#branch(arg0) ⇒ Session #branch(arg0) ⇒ Session
returns a default instance of HTTPX::Session.
50 51 52 53 54 |
# File 'lib/httpx/chainable.rb', line 50 def branch(, &blk) return self.class.new(, &blk) if is_a?(S) Session.new(, &blk) end |
#default_options ⇒ Options
returns default instance of HTTPX::Options.
45 46 47 |
# File 'lib/httpx/chainable.rb', line 45 def @options || Session. end |
#plugin(arg0, arg1) ⇒ Plugins::sessionAuth #plugin(arg0, arg1) ⇒ Plugins::sessionBasicAuth #plugin(arg0, arg1) ⇒ Plugins::sessionDigestAuth #plugin(arg0, arg1) ⇒ Plugins::sessionNTLMAuth #plugin(arg0, arg1) ⇒ Plugins::sessionNTLMV2Auth #plugin(arg0, arg1) ⇒ Plugins::sessionAwsSdkAuthentication #plugin(arg0, arg1) ⇒ Session #plugin(arg0, arg1) ⇒ Plugins::sessionCookies #plugin(arg0, arg1) ⇒ Session #plugin(arg0, arg1) ⇒ Plugins::sessionFollowRedirects #plugin(arg0, arg1) ⇒ Plugins::sessionUpgrade #plugin(arg0, arg1) ⇒ Plugins::sessionUpgrade #plugin(arg0, arg1) ⇒ Plugins::sessionUpgrade #plugin(arg0, arg1) ⇒ Plugins::sessionFiberConcurrency #plugin(arg0, arg1) ⇒ Plugins::sessionPersistent #plugin(arg0, arg1) ⇒ Plugins::sessionProxy & Plugins::httpProxy #plugin(arg0, arg1) ⇒ Plugins::sessionPushPromise #plugin(arg0, arg1) ⇒ Plugins::sessionRetries #plugin(arg0, arg1) ⇒ Plugins::sessionRateLimiter #plugin(arg0, arg1) ⇒ Plugins::sessionStream #plugin(arg0, arg1) ⇒ Plugins::sessionStreamBidi #plugin(arg0, arg1) ⇒ Plugins::sessionServerSentEvents #plugin(arg0, arg1) ⇒ Plugins::awsSigV4Session #plugin(arg0, arg1) ⇒ Plugins::grpcSession #plugin(arg0, arg1) ⇒ Plugins::sessionCache #plugin(arg0, arg1) ⇒ Plugins::sessionResponseCache #plugin(arg0, arg1) ⇒ Plugins::sessionCircuitBreaker #plugin(arg0, arg1) ⇒ Plugins::sessionOAuth #plugin(arg0, arg1) ⇒ Plugins::sessionCallbacks #plugin(arg0, arg1) ⇒ Plugins::sessionContentDigest #plugin(arg0, arg1) ⇒ Plugins::sessionSsrf #plugin(arg0, arg1) ⇒ Plugins::sessionWebDav #plugin(arg0, arg1) ⇒ Plugins::sessionXML #plugin(arg0, arg1) ⇒ Plugins::sessionQuery #plugin(arg0, arg1) ⇒ Plugins::sessionTracing #plugin(arg0, arg1) ⇒ Session #plugin(arg0, arg1) ⇒ Session
returns a new instance loaded with the pl plugin and options.
30 31 32 33 34 35 |
# File 'lib/httpx/chainable.rb', line 30 def plugin(pl, = nil, &blk) klass = is_a?(S) ? self.class : Session klass = Class.new(klass) klass.instance_variable_set(:@default_options, klass..merge()) klass.plugin(pl, , &blk).new end |
#request(arg0, arg1) ⇒ response #request(arg0, arg1) ⇒ Array[response] #request(arg0, arg1, arg2) ⇒ response #request(arg0, arg1) ⇒ Array[response] #request(arg0, arg1, arg2) ⇒ Array[response]
delegates to the default session (see HTTPX::Session#request).
16 17 18 |
# File 'lib/httpx/chainable.rb', line 16 def request(*args, **) branch().request(*args, **) end |
#with(arg0) ⇒ Session #with(arg0) ⇒ void
returns a new instance loaded with options.
38 39 40 |
# File 'lib/httpx/chainable.rb', line 38 def with(, &blk) branch(.merge(), &blk) end |
#wrap {|arg0| ... } ⇒ void
This method returns an undefined value.
delegates to the default session (see HTTPX::Session#wrap).
25 26 27 |
# File 'lib/httpx/chainable.rb', line 25 def wrap(&blk) branch().wrap(&blk) end |