Sha256: 4e85301e7ba0551c62603aadaba7a2ced6cc078913a475dd47131d790a3ef2a3

Contents?: true

Size: 1.2 KB

Versions: 9

Compression:

Stored size: 1.2 KB

Contents

require 'faraday/adapter/net_http'

module Faraday
  class Adapter
    # Experimental adapter for net-http-persistent
    class NetHttpPersistent < NetHttp
      dependency 'net/http/persistent'

      # TODO: investigate is it safe to create a new Persistent instance for
      # every request, or does it defy the purpose of persistent connections
      def net_http_connection(env)
        Net::HTTP::Persistent.new 'Faraday',
          env[:request][:proxy] ? env[:request][:proxy][:uri] : nil
      end

      def perform_request(http, env)
        http.request env[:url], create_request(env)
      rescue Net::HTTP::Persistent::Error => error
        if error.message.include? 'Timeout::Error'
          raise Faraday::Error::TimeoutError, error
        else
          raise
        end
      end

      def configure_ssl(http, ssl)
        http.verify_mode  = ssl_verify_mode(ssl)
        http.cert_store   = ssl_cert_store(ssl)

        http.certificate  = ssl[:client_cert]  if ssl[:client_cert]
        http.private_key  = ssl[:client_key]   if ssl[:client_key]
        http.ca_file      = ssl[:ca_file]      if ssl[:ca_file]
        http.ssl_version  = ssl[:version]      if ssl[:version]
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 3 rubygems

Version Path
faraday-0.8.7 lib/faraday/adapter/net_http_persistent.rb
vagrant-actionio-0.0.9 vendor/bundle/gems/faraday-0.8.6/lib/faraday/adapter/net_http_persistent.rb
faraday-0.8.6 lib/faraday/adapter/net_http_persistent.rb
faraday-0.8.5 lib/faraday/adapter/net_http_persistent.rb
faraday-0.8.4 lib/faraday/adapter/net_http_persistent.rb
faraday-0.8.2 lib/faraday/adapter/net_http_persistent.rb
avdi-faraday-0.8.1 lib/faraday/adapter/net_http_persistent.rb
faraday-0.8.1 lib/faraday/adapter/net_http_persistent.rb
faraday-0.8.0 lib/faraday/adapter/net_http_persistent.rb