class Faraday::Adapter
Base class for all Faraday
adapters. Adapters are responsible for fulfilling a Faraday
request.
Constants
- CONTENT_LENGTH
- TIMEOUT_KEYS
Public Class Methods
# File lib/faraday/adapter.rb, line 28 def initialize(_app = nil, opts = {}, &block) @app = lambda(&:response) @connection_options = opts @config_block = block end
Public Instance Methods
# File lib/faraday/adapter.rb, line 55 def call(env) env.clear_body if env.needs_body? env.response = Response.new end
Close any persistent connections. The adapter should still be usable after calling close.
# File lib/faraday/adapter.rb, line 50 def close # Possible implementation: # @app.close if @app.respond_to?(:close) end
Yields or returns an adapter’s configured connection. Depends on build_connection being defined on this adapter.
@param env [Faraday::Env, Hash] The env object for a faraday request.
@return The return value of the given block, or the HTTP connection object
if no block is given.
# File lib/faraday/adapter.rb, line 41 def connection(env) conn = build_connection(env) return conn unless block_given? yield conn end