Class: AWS::Core::Http::Request
- Inherits:
-
Object
- Object
- AWS::Core::Http::Request
- Defined in:
- lib/aws/core/http/request.rb
Overview
Base class for all service reqeusts. This class describes a basic HTTP request, but will not make one. It is consumed by a HTTP handler class that sends the actual request and parses the actual response.
Instance Attribute Summary collapse
-
#default_read_timeout ⇒ Integer
The number of seconds the service has to respond before a timeout error is raised on the request.
-
#headers ⇒ CaseInsensitiveHash
Request headers.
-
#host ⇒ String
Hostname of the request.
-
#http_method ⇒ String
GET, PUT POST, HEAD or DELETE, defaults to POST.
-
#params ⇒ Array
An array of request params, each param responds to #name and #value.
-
#path ⇒ String
Path of the request URI, defaults to /.
-
#proxy_uri ⇒ nil, URI
The URI to the proxy server requests are sent through if configured.
-
#region ⇒ String
The region name this request is for.
-
#service_ruby_name ⇒ String
The snake-cased ruby name for the service (e.g. ‘s3’, ‘iam’, ‘dynamo_db’, etc).
Instance Method Summary collapse
-
#add_param(name_or_param, value = nil) ⇒ Object
(also: #[]=)
Adds a request param.
-
#body ⇒ String?
Returns the request body.
-
#initialize ⇒ Request
constructor
Returns a new empty http request object.
-
#port ⇒ Integer
Returns the port the request will be made over.
-
#port=(port_number) ⇒ Object
Override the default port (443 or 80).
-
#querystring ⇒ String?
Returns the requesty querystring.
-
#ssl_ca_file ⇒ String
Path to a bundle of CA certs in PEM format; the HTTP handler should use this to verify all HTTPS requests if #ssl_verify_peer? is true.
- #ssl_ca_file=(ca_file) ⇒ Object
-
#ssl_ca_path ⇒ String
Path to a bundle of CA certs in PEM format; the HTTP handler should use this to verify all HTTPS requests if #ssl_verify_peer? is true.
- #ssl_ca_path=(ca_path) ⇒ Object
- #ssl_verify_peer=(verify_peer) ⇒ Object
-
#ssl_verify_peer? ⇒ Boolean
If the client should verify the peer certificate or not.
-
#uri ⇒ String
The request uri.
-
#url_encoded_params ⇒ String
Returns the request params url encoded, or nil if this request has no params.
- #use_ssl=(state) ⇒ Object
-
#use_ssl? ⇒ Boolean
If this request should be sent over ssl or not.
Constructor Details
#initialize ⇒ Request
Returns a new empty http request object.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/aws/core/http/request.rb', line 25 def initialize @host = nil @http_method = 'POST' @path = '/' @headers = CaseInsensitiveHash.new @params = [] @use_ssl = true @port = nil @default_read_timeout = 60 end |
Instance Attribute Details
#default_read_timeout ⇒ Integer
Returns The number of seconds the service has to respond before a timeout error is raised on the request. Defaults to 60 seconds.
39 40 41 |
# File 'lib/aws/core/http/request.rb', line 39 def default_read_timeout @default_read_timeout end |
#headers ⇒ CaseInsensitiveHash
Returns request headers.
49 50 51 |
# File 'lib/aws/core/http/request.rb', line 49 def headers @headers end |
#host ⇒ String
Returns hostname of the request.
46 47 48 |
# File 'lib/aws/core/http/request.rb', line 46 def host @host end |
#http_method ⇒ String
Returns GET, PUT POST, HEAD or DELETE, defaults to POST.
56 57 58 |
# File 'lib/aws/core/http/request.rb', line 56 def http_method @http_method end |
#params ⇒ Array
Returns An array of request params, each param responds to #name and #value.
53 54 55 |
# File 'lib/aws/core/http/request.rb', line 53 def params @params end |
#path ⇒ String
Returns path of the request URI, defaults to /.
59 60 61 |
# File 'lib/aws/core/http/request.rb', line 59 def path @path end |
#proxy_uri ⇒ nil, URI
Returns The URI to the proxy server requests are sent through if configured. Returns nil if there is no proxy.
63 64 65 |
# File 'lib/aws/core/http/request.rb', line 63 def proxy_uri @proxy_uri end |
#region ⇒ String
Returns The region name this request is for. Only needs to be populated for requests against signature v4 endpoints.
67 68 69 |
# File 'lib/aws/core/http/request.rb', line 67 def region @region end |
#service_ruby_name ⇒ String
Returns The snake-cased ruby name for the service (e.g. ‘s3’, ‘iam’, ‘dynamo_db’, etc).
43 44 45 |
# File 'lib/aws/core/http/request.rb', line 43 def service_ruby_name @service_ruby_name end |
Instance Method Details
#add_param(param_name, param_value = nil) ⇒ Object #add_param(param_obj) ⇒ Object Also known as: []=
Adds a request param.
155 156 157 158 159 160 161 |
# File 'lib/aws/core/http/request.rb', line 155 def add_param name_or_param, value = nil if name_or_param.kind_of?(Param) @params << name_or_param else @params << Param.new(name_or_param, value) end end |
#body ⇒ String?
Returns the request body.
197 198 199 |
# File 'lib/aws/core/http/request.rb', line 197 def body url_encoded_params end |
#port ⇒ Integer
Returns the port the request will be made over. Defaults to 443 for SSL requests and 80 for non-SSL requests.
100 101 102 |
# File 'lib/aws/core/http/request.rb', line 100 def port @port || (use_ssl? ? 443 : 80) end |
#port=(port_number) ⇒ Object
Override the default port (443 or 80). If you pass nil then the default port will take precedence.
94 95 96 |
# File 'lib/aws/core/http/request.rb', line 94 def port= port_number @port = port_number end |
#querystring ⇒ String?
Returns the requesty querystring.
192 193 194 |
# File 'lib/aws/core/http/request.rb', line 192 def querystring nil end |
#ssl_ca_file ⇒ String
Returns Path to a bundle of CA certs in PEM format; the HTTP handler should use this to verify all HTTPS requests if #ssl_verify_peer? is true.
126 127 128 |
# File 'lib/aws/core/http/request.rb', line 126 def ssl_ca_file @ssl_ca_file end |
#ssl_ca_file=(ca_file) ⇒ Object
119 120 121 |
# File 'lib/aws/core/http/request.rb', line 119 def ssl_ca_file=(ca_file) @ssl_ca_file = ca_file end |
#ssl_ca_path ⇒ String
Returns Path to a bundle of CA certs in PEM format; the HTTP handler should use this to verify all HTTPS requests if #ssl_verify_peer? is true.
140 141 142 |
# File 'lib/aws/core/http/request.rb', line 140 def ssl_ca_path @ssl_ca_path end |
#ssl_ca_path=(ca_path) ⇒ Object
133 134 135 |
# File 'lib/aws/core/http/request.rb', line 133 def ssl_ca_path=(ca_path) @ssl_ca_path = ca_path end |
#ssl_verify_peer=(verify_peer) ⇒ Object
106 107 108 |
# File 'lib/aws/core/http/request.rb', line 106 def ssl_verify_peer=(verify_peer) @ssl_verify_peer = verify_peer end |
#ssl_verify_peer? ⇒ Boolean
Returns If the client should verify the peer certificate or not.
112 113 114 |
# File 'lib/aws/core/http/request.rb', line 112 def ssl_verify_peer? @ssl_verify_peer end |
#uri ⇒ String
Returns the request uri.
177 178 179 |
# File 'lib/aws/core/http/request.rb', line 177 def uri querystring ? "#{path}?#{querystring}" : path end |
#url_encoded_params ⇒ String
Returns the request params url encoded, or nil if this request has no params.
183 184 185 186 187 188 189 |
# File 'lib/aws/core/http/request.rb', line 183 def url_encoded_params if @params.empty? nil else @params.sort.collect{|p| p.encoded }.join('&') end end |
#use_ssl=(state) ⇒ Object
82 83 84 |
# File 'lib/aws/core/http/request.rb', line 82 def use_ssl= state @use_ssl = state end |
#use_ssl? ⇒ Boolean
Returns If this request should be sent over ssl or not.
87 88 89 |
# File 'lib/aws/core/http/request.rb', line 87 def use_ssl? @use_ssl end |