Sha256: 9ae146f4be0fb33a923467656ac5188dcc0e7a538fa4629971de2867506623ef

Contents?: true

Size: 1.44 KB

Versions: 13

Compression:

Stored size: 1.44 KB

Contents

module Faraday
  # Public: This is a base class for all Faraday adapters.  Adapters are
  # responsible for fulfilling a Faraday request.
  class Adapter < Middleware
    CONTENT_LENGTH = 'Content-Length'.freeze

    register_middleware File.expand_path('../adapter', __FILE__),
      :test => [:Test, 'test'],
      :net_http => [:NetHttp, 'net_http'],
      :net_http_persistent => [:NetHttpPersistent, 'net_http_persistent'],
      :typhoeus => [:Typhoeus, 'typhoeus'],
      :patron => [:Patron, 'patron'],
      :em_synchrony => [:EMSynchrony, 'em_synchrony'],
      :em_http => [:EMHttp, 'em_http'],
      :excon => [:Excon, 'excon'],
      :rack => [:Rack, 'rack'],
      :httpclient => [:HTTPClient, 'httpclient']

    # Public: This module marks an Adapter as supporting parallel requests.
    module Parallelism
      attr_writer :supports_parallel
      def supports_parallel?() @supports_parallel end

      def inherited(subclass)
        super
        subclass.supports_parallel = self.supports_parallel?
      end
    end

    extend Parallelism
    self.supports_parallel = false

    def call(env)
      env.clear_body if env.needs_body?
    end

    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
  end
end

Version data entries

13 entries across 13 versions & 6 rubygems

Version Path
mercadopago-custom-checkout-0.1.2 .gs/gems/faraday-0.9.2/lib/faraday/adapter.rb
mercadopago-custom-checkout-0.1.1 .gs/gems/faraday-0.9.2/lib/faraday/adapter.rb
logstash-input-salesforce-3.0.0 vendor/jruby/1.9/gems/faraday-0.9.2/lib/faraday/adapter.rb
second_step-0.1.2 secondstep-notify-1.0.0-osx/lib/ruby/lib/ruby/gems/2.2.0/gems/faraday-0.9.2/lib/faraday/adapter.rb
tdiary-5.0.2 vendor/bundle/gems/faraday-0.9.2/lib/faraday/adapter.rb
tdiary-5.0.1 vendor/bundle/gems/faraday-0.9.2/lib/faraday/adapter.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/faraday-0.9.2/lib/faraday/adapter.rb
faraday-0.9.2 lib/faraday/adapter.rb
faraday-0.9.1 lib/faraday/adapter.rb
whos_dated_who-0.1.0 vendor/bundle/gems/faraday-0.9.0/lib/faraday/adapter.rb
whos_dated_who-0.0.1 vendor/bundle/gems/faraday-0.9.0/lib/faraday/adapter.rb
faraday-0.9.0 lib/faraday/adapter.rb
faraday-0.9.0.rc7 lib/faraday/adapter.rb