Class: Faraday::Adapter

Inherits:
Middleware show all
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

#response_headers(env) ⇒ Object



34
35
36
# File 'lib/faraday/adapter.rb', line 34

def response_headers(env)
  env[:response_headers] ||= Utils::Headers.new
end