Sha256: 4509d1ce5d4a784a4f7f0448d1fe5cdc42b0ba8acf2964332212aa31684e5dd7

Contents?: true

Size: 1.68 KB

Versions: 52

Compression:

Stored size: 1.68 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 initialize(app = nil, opts = {}, &block)
      super(app)
      @connection_options = opts
      @config_block = block
    end

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

    private

    def save_response(env, status, body, headers = nil, reason_phrase = nil)
      env.status = status
      env.body = body
      env.reason_phrase = reason_phrase && reason_phrase.to_s.strip
      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

52 entries across 49 versions & 4 rubygems

Version Path
faraday-0.17.6 lib/faraday/adapter.rb
faraday-0.17.5 lib/faraday/adapter.rb
logstash-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/faraday-0.15.4/lib/faraday/adapter.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/faraday-0.15.4/lib/faraday/adapter.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/faraday-0.15.4/lib/faraday/adapter.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/faraday-0.15.4/lib/faraday/adapter.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/faraday-0.15.4/lib/faraday/adapter.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/faraday-0.15.4/lib/faraday/adapter.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/faraday-0.15.4/lib/faraday/adapter.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/faraday-0.15.4/lib/faraday/adapter.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/faraday-0.15.4/lib/faraday/adapter.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/faraday-0.15.4/lib/faraday/adapter.rb
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/faraday-0.15.4/lib/faraday/adapter.rb
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/faraday-0.15.4/lib/faraday/adapter.rb
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/faraday-0.15.4/lib/faraday/adapter.rb
logstash-output-scalyr-0.1.16.beta vendor/bundle/jruby/2.5.0/gems/faraday-0.15.4/lib/faraday/adapter.rb
logstash-output-scalyr-0.1.15.beta vendor/bundle/jruby/2.5.0/gems/faraday-0.15.4/lib/faraday/adapter.rb
logstash-output-scalyr-0.1.14.beta vendor/bundle/jruby/2.5.0/gems/faraday-0.15.4/lib/faraday/adapter.rb
logstash-output-scalyr-0.1.13 vendor/bundle/jruby/2.5.0/gems/faraday-0.15.4/lib/faraday/adapter.rb
logstash-output-scalyr-0.1.12 vendor/bundle/jruby/2.5.0/gems/faraday-0.15.4/lib/faraday/adapter.rb