Class: Faraday::Adapter::NetHttpPersistent
- Inherits:
-
NetHttp
- Object
- Middleware
- Faraday::Adapter
- NetHttp
- Faraday::Adapter::NetHttpPersistent
- Defined in:
- lib/faraday/adapter/net_http_persistent.rb
Overview
Experimental adapter for net-http-persistent
Constant Summary
Constants inherited from NetHttp
Faraday::Adapter::NetHttp::NET_HTTP_EXCEPTIONS
Constants inherited from Faraday::Adapter
Instance Attribute Summary
Attributes included from Parallelism
Instance Method Summary collapse
- #configure_ssl(http, ssl) ⇒ Object
-
#net_http_connection(env) ⇒ Object
TODO: investigate is it safe to create a new Persistent instance for every request, or does it defy the purpose of persistent connections.
- #perform_request(http, env) ⇒ Object
Methods inherited from NetHttp
#call, #create_request, #ssl_cert_store, #ssl_verify_mode
Methods inherited from Faraday::Adapter
#call, #prepend_proxy_auth_string, #save_response
Methods included from Faraday::AutoloadHelper
#all_loaded_constants, #autoload_all, #load_autoloaded_constants
Methods included from MiddlewareRegistry
#lookup_middleware, #register_middleware
Methods included from Parallelism
#inherited, #supports_parallel?
Methods inherited from Middleware
dependency, inherited, #initialize, loaded?, new
Constructor Details
This class inherits a constructor from Faraday::Middleware
Instance Method Details
#configure_ssl(http, ssl) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/faraday/adapter/net_http_persistent.rb', line 26 def configure_ssl(http, ssl) http.verify_mode = ssl_verify_mode(ssl) http.cert_store = ssl_cert_store(ssl) http.certificate = ssl[:client_cert] if ssl[:client_cert] http.private_key = ssl[:client_key] if ssl[:client_key] http.ca_file = ssl[:ca_file] if ssl[:ca_file] http.ssl_version = ssl[:version] if ssl[:version] end |
#net_http_connection(env) ⇒ Object
TODO: investigate is it safe to create a new Persistent instance for every request, or does it defy the purpose of persistent connections
11 12 13 14 |
# File 'lib/faraday/adapter/net_http_persistent.rb', line 11 def net_http_connection(env) Net::HTTP::Persistent.new 'Faraday', env[:request][:proxy] ? env[:request][:proxy][:uri] : nil end |
#perform_request(http, env) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/faraday/adapter/net_http_persistent.rb', line 16 def perform_request(http, env) http.request env[:url], create_request(env) rescue Net::HTTP::Persistent::Error => error if error..include? 'Timeout::Error' raise Faraday::Error::TimeoutError, error else raise end end |