Sha256: 9f5b0c934dee29858136aa6e23a9e1e80cd962defdad1776a8adab74a6f3ce6b

Contents?: true

Size: 797 Bytes

Versions: 1

Compression:

Stored size: 797 Bytes

Contents

module Faraday
  class Adapter
    class Patron < Faraday::Adapter
      dependency 'patron'

      def call(env)
        super

        # TODO: support streaming requests
        env[:body] = env[:body].read if env[:body].respond_to? :read

        session = ::Patron::Session.new

        response = begin
          if Connection::METHODS_WITH_BODIES.include? env[:method]
            session.send(env[:method], env[:url].to_s, env[:body].to_s, env[:request_headers])
          else
            session.send(env[:method], env[:url].to_s, env[:request_headers])
          end
        rescue Errno::ECONNREFUSED
          raise Error::ConnectionFailed, $!
        end

        save_response(env, response.status, response.body, response.headers)

        @app.call env
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
faraday-0.6.1 lib/faraday/adapter/patron.rb