lib/faraday/adapter/net_http.rb in faraday-net_http-0.0.5 vs lib/faraday/adapter/net_http.rb in faraday-net_http-0.0.6
- old
+ new
@@ -7,14 +7,12 @@
'Make sure openssl is installed if you want ssl support'
require 'net/http'
end
require 'zlib'
-# rubocop:disable Metrics/ClassLength
module Faraday
class Adapter
- # Net::HTTP adapter.
class NetHttp < Faraday::Adapter
exceptions = [
IOError,
Errno::EADDRNOTAVAIL,
Errno::ECONNABORTED,
@@ -61,15 +59,17 @@
end
def call(env)
super
http_response = connection(env) do |http|
- perform_request(http, env)
- rescue *NET_HTTP_EXCEPTIONS => e
- raise Faraday::SSLError, e if defined?(OpenSSL) && e.is_a?(OpenSSL::SSL::SSLError)
+ begin
+ perform_request(http, env)
+ rescue *NET_HTTP_EXCEPTIONS => e
+ raise Faraday::SSLError, e if defined?(OpenSSL) && e.is_a?(OpenSSL::SSL::SSLError)
- raise Faraday::ConnectionFailed, e
+ raise Faraday::ConnectionFailed, e
+ end
end
save_response(env, http_response.code.to_i,
http_response.body || +'', nil,
http_response.message) do |response_headers|
@@ -151,11 +151,10 @@
opened_http.request create_request(env)
end
end
end
- # rubocop:disable Metrics/AbcSize
def configure_ssl(http, ssl)
return unless ssl
http.verify_mode = ssl_verify_mode(ssl)
http.cert_store = ssl_cert_store(ssl)
@@ -167,11 +166,10 @@
http.verify_depth = ssl[:verify_depth] if ssl[:verify_depth]
http.ssl_version = ssl[:version] if ssl[:version]
http.min_version = ssl[:min_version] if ssl[:min_version]
http.max_version = ssl[:max_version] if ssl[:max_version]
end
- # rubocop:enable Metrics/AbcSize
def configure_request(http, req)
if (sec = request_timeout(:read, req))
http.read_timeout = sec
end
@@ -210,6 +208,5 @@
end
end
end
end
end
-# rubocop:enable Metrics/ClassLength