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.
Instance Attribute Summary collapse
-
#access_key_id ⇒ String
The AWS access key ID used to authorize the request.
-
#headers ⇒ CaseInsensitiveHash
readonly
Request headers.
-
#host ⇒ String
Hostname of the request.
-
#http_method ⇒ String
GET, PUT POST, HEAD or DELETE, defaults to POST.
-
#params ⇒ Array
readonly
An array of request params, each param responds to #name and #value.
-
#path ⇒ String
readonly
Path of the request URI, defaults to /.
-
#proxy_uri ⇒ nil, URI
The URI to the proxy server requests are sent through if configured.
Instance Method Summary collapse
-
#add_param(name_or_param, value = nil) ⇒ Object
Adds a request param.
-
#body ⇒ String?
Returns the request body.
-
#initialize ⇒ Request
constructor
Returns a new empty http request object.
-
#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_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=(use_ssl) ⇒ 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.
22 23 24 25 26 27 28 29 |
# File 'lib/aws/core/http/request.rb', line 22 def initialize @host = nil @http_method = 'POST' @path = '/' @headers = CaseInsensitiveHash.new @params = [] @use_ssl = true end |
Instance Attribute Details
#access_key_id ⇒ String
Returns the AWS access key ID used to authorize the request.
49 50 51 |
# File 'lib/aws/core/http/request.rb', line 49 def access_key_id @access_key_id end |
#headers ⇒ CaseInsensitiveHash (readonly)
Returns request headers.
35 36 37 |
# File 'lib/aws/core/http/request.rb', line 35 def headers @headers end |
#host ⇒ String
Returns hostname of the request.
32 33 34 |
# File 'lib/aws/core/http/request.rb', line 32 def host @host end |
#http_method ⇒ String
Returns GET, PUT POST, HEAD or DELETE, defaults to POST.
42 43 44 |
# File 'lib/aws/core/http/request.rb', line 42 def http_method @http_method end |
#params ⇒ Array (readonly)
Returns An array of request params, each param responds to #name and #value.
39 40 41 |
# File 'lib/aws/core/http/request.rb', line 39 def params @params end |
#path ⇒ String (readonly)
Returns path of the request URI, defaults to /.
45 46 47 |
# File 'lib/aws/core/http/request.rb', line 45 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.
53 54 55 |
# File 'lib/aws/core/http/request.rb', line 53 def proxy_uri @proxy_uri end |
Instance Method Details
#add_param(param_name, param_value = nil) ⇒ Object #add_param(param_obj) ⇒ Object
Adds a request param.
102 103 104 105 106 107 108 |
# File 'lib/aws/core/http/request.rb', line 102 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.
137 138 139 |
# File 'lib/aws/core/http/request.rb', line 137 def body url_encoded_params end |
#querystring ⇒ String?
Returns the requesty querystring.
132 133 134 |
# File 'lib/aws/core/http/request.rb', line 132 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.
87 88 89 |
# File 'lib/aws/core/http/request.rb', line 87 def ssl_ca_file @ssl_ca_file end |
#ssl_ca_file=(ca_file) ⇒ Object
80 81 82 |
# File 'lib/aws/core/http/request.rb', line 80 def ssl_ca_file=(ca_file) @ssl_ca_file = ca_file end |
#ssl_verify_peer=(verify_peer) ⇒ Object
67 68 69 |
# File 'lib/aws/core/http/request.rb', line 67 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.
73 74 75 |
# File 'lib/aws/core/http/request.rb', line 73 def ssl_verify_peer? @ssl_verify_peer end |
#uri ⇒ String
Returns the request uri.
117 118 119 |
# File 'lib/aws/core/http/request.rb', line 117 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.
123 124 125 126 127 128 129 |
# File 'lib/aws/core/http/request.rb', line 123 def url_encoded_params if @params.empty? nil else @params.sort.collect{|p| p.encoded }.join('&') end end |
#use_ssl=(use_ssl) ⇒ Object
56 57 58 |
# File 'lib/aws/core/http/request.rb', line 56 def use_ssl= use_ssl @use_ssl = use_ssl end |
#use_ssl? ⇒ Boolean
Returns If this request should be sent over ssl or not.
61 62 63 |
# File 'lib/aws/core/http/request.rb', line 61 def use_ssl? @use_ssl end |