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  

Public Class methods

new (app)
[show source]
    # File lib/httpx/adapters/faraday.rb
171 def initialize(app)
172   super(app)
173   @session = Session.new
174 end
setup_parallel_manager ()
[show source]
    # File lib/httpx/adapters/faraday.rb
166 def setup_parallel_manager
167   ParallelManager.new
168 end

Public Instance methods

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