Class: AWS::Core::Http::NetHttpHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/core/http/net_http_handler.rb

Overview

The default http request handler for the aws-sdk gem. It is based on Net::Http.

Constant Summary collapse

@@pool =
Net::HTTP::ConnectionPool.new

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.poolObject



27
28
29
# File 'lib/aws/core/http/net_http_handler.rb', line 27

def self.pool
  @@pool
end

Instance Method Details

#handle(request, response) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/aws/core/http/net_http_handler.rb', line 31

def handle request, response

  options = {}
  options[:ssl] = request.use_ssl?
  options[:proxy_uri] = request.proxy_uri
  options[:ssl_verify_peer] = request.ssl_verify_peer?
  options[:ssl_ca_file] = request.ssl_ca_file if request.ssl_ca_file
  options[:ssl_ca_path] = request.ssl_ca_path if request.ssl_ca_path

  connection = self.class.pool.connection_for(request.host, options)
  connection.read_timeout = request.read_timeout

  begin
    http_response = connection.request(build_request(request))
    response.body = http_response.body
    response.status = http_response.code.to_i
    response.headers = http_response.to_hash
  rescue Timeout::Error, Errno::ETIMEDOUT => e
    response.timeout = true
  end

end