Class: Faraday::Adapter
- Inherits:
-
Middleware
- Object
- Middleware
- Faraday::Adapter
- Extended by:
- AutoloadHelper
- Defined in:
- lib/faraday/adapter.rb,
lib/faraday/adapter/test.rb,
lib/faraday/adapter/excon.rb,
lib/faraday/adapter/patron.rb,
lib/faraday/adapter/net_http.rb,
lib/faraday/adapter/typhoeus.rb,
lib/faraday/adapter/em_synchrony.rb,
lib/faraday/adapter/action_dispatch.rb
Direct Known Subclasses
ActionDispatch, EMSynchrony, Excon, NetHttp, Patron, Test, Typhoeus
Defined Under Namespace
Classes: ActionDispatch, EMSynchrony, Excon, NetHttp, Patron, Test, Typhoeus
Constant Summary collapse
- CONTENT_LENGTH =
'Content-Length'.freeze
Instance Method Summary collapse
Methods included from AutoloadHelper
all_loaded_constants, autoload_all, load_autoloaded_constants, lookup_module, register_lookup_modules
Methods inherited from Middleware
dependency, #initialize, loaded?, setup_parallel_manager
Constructor Details
This class inherits a constructor from Faraday::Middleware
Instance Method Details
#call(env) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/faraday/adapter.rb', line 25 def call(env) if !env[:body] and Connection::METHODS_WITH_BODIES.include? env[:method] # play nice and indicate we're sending an empty body env[:request_headers][CONTENT_LENGTH] = "0" # Typhoeus hangs on PUT requests if body is nil env[:body] = '' end end |
#save_response(env, status, body, headers = nil) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/faraday/adapter.rb', line 34 def save_response(env, status, body, headers = nil) env[:status] = status env[:body] = body env[:response_headers] = Utils::Headers.new.tap do |response_headers| response_headers.update headers unless headers.nil? yield response_headers if block_given? end end |