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
returns a new session with the "Accept" header set to
type. -
#plugin(pl, options = nil) {|arg0| ... } ⇒ Object
returns a new instance loaded with the
plplugin andoptions. -
#request ⇒ 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)
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/httpx/chainable.rb', line 59 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
returns a new session with the "Accept" header set to type.
23 24 25 |
# File 'lib/httpx/chainable.rb', line 23 def accept(type) with(headers: { "accept" => String(type) }) 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) ⇒ Plugins::sessionHedging #plugin(arg0, arg1) ⇒ Session #plugin(arg0, arg1) ⇒ Session
returns a new instance loaded with the pl plugin and options.
33 34 35 36 37 38 |
# File 'lib/httpx/chainable.rb', line 33 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, arg2) ⇒ response #request(arg0, arg1) ⇒ Array[response] #request(arg0, arg1, arg2) ⇒ Array[response]
delegates to the default session (see HTTPX::Session#request).
18 19 20 |
# File 'lib/httpx/chainable.rb', line 18 def request(...) branch().request(...) end |
#with(arg0) ⇒ Session #with(arg0) ⇒ void
returns a new instance loaded with options.
41 42 43 |
# File 'lib/httpx/chainable.rb', line 41 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).
28 29 30 |
# File 'lib/httpx/chainable.rb', line 28 def wrap(&blk) branch().wrap(&blk) end |