Class: Faraday::Adapter::HTTPX
- Inherits:
-
Faraday::Adapter
- Object
- Faraday::Adapter
- Faraday::Adapter::HTTPX
- Includes:
- RequestMixin
- Defined in:
- lib/httpx/adapters/faraday.rb
Defined Under Namespace
Modules: OnDataPlugin, ReasonPlugin, RequestMixin Classes: ParallelManager
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app = nil, opts = {}, &block) ⇒ HTTPX
constructor
A new instance of HTTPX.
Methods included from RequestMixin
Constructor Details
#initialize(app = nil, opts = {}, &block) ⇒ HTTPX
Returns a new instance of HTTPX.
10 11 12 13 |
# File 'lib/httpx/adapters/faraday.rb', line 10 def initialize(app = nil, opts = {}, &block) @connection = @bind = nil super(app, opts, &block) end |
Class Method Details
.setup_parallel_manager(options = {}) ⇒ Object
252 253 254 |
# File 'lib/httpx/adapters/faraday.rb', line 252 def setup_parallel_manager( = {}) ParallelManager.new() end |
Instance Method Details
#call(env) ⇒ Object
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/httpx/adapters/faraday.rb', line 257 def call(env) super if parallel?(env) handler = env[:parallel_manager].enqueue(env) handler.on_response do |response| if response.is_a?(::HTTPX::Response) save_response(env, response.status, response.body.to_s, response.headers, response.reason) do |response_headers| response_headers.merge!(response.headers) end else env[:error] = response.error save_response(env, 0, "", {}, nil) end end return handler end response = connect_and_request(env) save_response(env, response.status, response.body.to_s, response.headers, response.reason) do |response_headers| response_headers.merge!(response.headers) end @app.call(env) end |