lib/httpx/adapters/faraday.rb in httpx-0.6.3 vs lib/httpx/adapters/faraday.rb in httpx-0.6.4
- old
+ new
@@ -4,10 +4,11 @@
require "faraday"
module Faraday
class Adapter
class HTTPX < Faraday::Adapter
+ # :nocov:
SSL_ERROR = if defined?(Faraday::SSLError)
Faraday::SSLError
else
Faraday::Error::SSLError
end
@@ -15,10 +16,11 @@
CONNECTION_FAILED_ERROR = if defined?(Faraday::ConnectionFailed)
Faraday::ConnectionFailed
else
Faraday::Error::ConnectionFailed
end
+ # :nocov:
module RequestMixin
private
def build_request(env)
@@ -61,10 +63,11 @@
class Session < ::HTTPX::Session
plugin(:compression)
plugin(:persistent)
+ # :nocov:
module ReasonPlugin
if RUBY_VERSION < "2.5"
def self.load_dependencies(*)
require "webrick"
end
@@ -83,10 +86,11 @@
Net::HTTP::STATUS_CODES.fetch(@status)
end
end
end
end
+ # :nocov:
plugin(ReasonPlugin)
end
class ParallelManager
class ResponseHandler
@@ -183,29 +187,29 @@
end
end
return handler
end
- request_options = build_request(env)
+ meth, uri, request_options = build_request(env)
session = @session.with(options_from_env(env))
session = session.plugin(:proxy).with_proxy(proxy_options) if env.request.proxy
- response = session.__send__(*request_options)
+ response = session.__send__(meth, uri, **request_options)
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 OpenSSL::SSL::SSLError => e
+ raise SSL_ERROR, e
rescue Errno::ECONNABORTED,
Errno::ECONNREFUSED,
Errno::ECONNRESET,
Errno::EHOSTUNREACH,
Errno::EINVAL,
Errno::ENETUNREACH,
- Errno::EPIPE => err
- raise CONNECTION_FAILED_ERROR, err
+ Errno::EPIPE => e
+ raise CONNECTION_FAILED_ERROR, e
end
private
def parallel?(env)