Class: Faraday::Adapter::NetHttp
- Inherits:
-
Faraday::Adapter
- Object
- Faraday::Adapter
- Faraday::Adapter::NetHttp
- Defined in:
- lib/faraday/adapter/net_http.rb
Overview
Net::HTTP adapter.
Direct Known Subclasses
Constant Summary collapse
- NET_HTTP_EXCEPTIONS =
exceptions.freeze
Constants inherited from Faraday::Adapter
Instance Attribute Summary
Attributes included from DependencyLoader
Attributes included from Parallelism
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app = nil, opts = {}, &block) ⇒ NetHttp
constructor
A new instance of NetHttp.
Methods included from MiddlewareRegistry
#fetch_middleware, #load_middleware, #lookup_middleware, #middleware_mutex, #register_middleware, #unregister_middleware
Methods included from DependencyLoader
#dependency, #inherited, #loaded?, #new
Methods included from Parallelism
#inherited, #supports_parallel?
Methods included from Faraday::AutoloadHelper
#all_loaded_constants, #autoload_all, #load_autoloaded_constants
Constructor Details
#initialize(app = nil, opts = {}, &block) ⇒ NetHttp
Returns a new instance of NetHttp.
38 39 40 41 |
# File 'lib/faraday/adapter/net_http.rb', line 38 def initialize(app = nil, opts = {}, &block) @ssl_cert_store = nil super(app, opts, &block) end |
Instance Method Details
#call(env) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/faraday/adapter/net_http.rb', line 43 def call(env) super with_net_http_connection(env) do |http| if (env[:url].scheme == 'https') && env[:ssl] configure_ssl(http, env[:ssl]) end configure_request(http, env[:request]) begin http_response = perform_request(http, env) rescue *NET_HTTP_EXCEPTIONS => e if defined?(OpenSSL) && e.is_a?(OpenSSL::SSL::SSLError) raise Faraday::SSLError, e end raise Faraday::ConnectionFailed, e end save_response(env, http_response.code.to_i, http_response.body || '', nil, http_response.) do |response_headers| http_response.each_header do |key, value| response_headers[key] = value end end end @app.call env rescue Timeout::Error, Errno::ETIMEDOUT => e raise Faraday::TimeoutError, e end |