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: RequestMixin Classes: ParallelManager, Session
Constant Summary collapse
- SSL_ERROR =
if defined?(Faraday::SSLError) Faraday::SSLError else Faraday::Error::SSLError end
- CONNECTION_FAILED_ERROR =
if defined?(Faraday::ConnectionFailed) Faraday::ConnectionFailed else Faraday::Error::ConnectionFailed end
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ HTTPX
constructor
A new instance of HTTPX.
Constructor Details
Class Method Details
.setup_parallel_manager ⇒ Object
166 167 168 |
# File 'lib/httpx/adapters/faraday.rb', line 166 def setup_parallel_manager ParallelManager.new end |
Instance Method Details
#call(env) ⇒ Object
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/httpx/adapters/faraday.rb', line 176 def call(env) super if parallel?(env) handler = env[:parallel_manager].enqueue(env) handler.on_response do |response| save_response(env, response.status, response.body.to_s, response.headers, response.reason) do |response_headers| response_headers.merge!(response.headers) end end return handler end = build_request(env) session = @session.with((env)) session = session.plugin(:proxy).with_proxy() if env.request.proxy response = session.__send__(*) response.raise_for_status unless 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 @app.call(env) rescue OpenSSL::SSL::SSLError => err raise SSL_ERROR, err rescue Errno::ECONNABORTED, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::EHOSTUNREACH, Errno::EINVAL, Errno::ENETUNREACH, Errno::EPIPE => err raise CONNECTION_FAILED_ERROR, err end |