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

Instance Method Summary collapse

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

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

  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