class Faraday::Adapter::HTTPX

  1. lib/httpx/adapters/faraday.rb
Superclass: Adapter

Methods

Public Class

  1. new
  2. setup_parallel_manager

Public Instance

  1. call

Included modules

  1. RequestMixin

Constants

CONNECTION_FAILED_ERROR = if defined?(Faraday::ConnectionFailed) Faraday::ConnectionFailed else Faraday::Error::ConnectionFailed end  
SSL_ERROR = if defined?(Faraday::SSLError) Faraday::SSLError else Faraday::Error::SSLError end  

:nocov:

Public Class methods

new (app)
[show source]
    # File lib/httpx/adapters/faraday.rb
175 def initialize(app)
176   super(app)
177   @session = Session.new
178 end
setup_parallel_manager ()
[show source]
    # File lib/httpx/adapters/faraday.rb
170 def setup_parallel_manager
171   ParallelManager.new
172 end

Public Instance methods

call (env)
[show source]
    # File lib/httpx/adapters/faraday.rb
180 def call(env)
181   super
182   if parallel?(env)
183     handler = env[:parallel_manager].enqueue(env)
184     handler.on_response do |response|
185       save_response(env, response.status, response.body.to_s, response.headers, response.reason) do |response_headers|
186         response_headers.merge!(response.headers)
187       end
188     end
189     return handler
190   end
191 
192   meth, uri, request_options = build_request(env)
193 
194   session = @session.with(options_from_env(env))
195   session = session.plugin(:proxy).with(proxy: proxy_options) if env.request.proxy
196   response = session.__send__(meth, uri, **request_options)
197   response.raise_for_status unless response.is_a?(::HTTPX::Response)
198   save_response(env, response.status, response.body.to_s, response.headers, response.reason) do |response_headers|
199     response_headers.merge!(response.headers)
200   end
201   @app.call(env)
202 rescue OpenSSL::SSL::SSLError => e
203   raise SSL_ERROR, e
204 rescue Errno::ECONNABORTED,
205        Errno::ECONNREFUSED,
206        Errno::ECONNRESET,
207        Errno::EHOSTUNREACH,
208        Errno::EINVAL,
209        Errno::ENETUNREACH,
210        Errno::EPIPE => e
211   raise CONNECTION_FAILED_ERROR, e
212 end