Base class for all service reqeusts.
@return [String] the AWS access key ID used to authorize the
request
@return [CaseInsensitiveHash] request headers
@return [String] hostname of the request
@return [String] GET, PUT POST, HEAD or DELETE, defaults to POST
@return [Array] An array of request params, each param responds to
#name and #value.
@return [String] path of the request URI, defaults to /
@return [nil, URI] The URI to the proxy server requests are
sent through if configured. Returns nil if there is no proxy.
@return [Integer] The number of seconds the service has to respond
before a timeout error is raised on the request. Defaults to 60 seconds.
@return [String] The region name this request is for. Only needs
to be populated for requests against signature v4 endpoints.
@return [String] The snake-cased ruby name for the service
(e.g. 's3', 'iam', 'dynamo_db', etc).
Returns a new empty http request object.
# File lib/aws/core/http/request.rb, line 22 def initialize @host = nil @http_method = 'POST' @path = '/' @headers = CaseInsensitiveHash.new @params = [] @use_ssl = true @port = nil @read_timeout = 60 end
Adds a request param.
@overload #add_param(param_name, param_value = nil)
Add a param (name/value) @param [String] param_name @param [String] param_value Leave blank for sub resources
@overload #add_param(param_obj)
Add a param (object) @param [Param] param_obj
# File lib/aws/core/http/request.rb, line 144 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
@return [String, nil] Returns the request body.
# File lib/aws/core/http/request.rb, line 186 def body url_encoded_params end
@private
# File lib/aws/core/http/request.rb, line 154 def get_param param_name @params.detect{|p| p.name == param_name } || raise("undefined param #{param_name}") end
@private
# File lib/aws/core/http/request.rb, line 160 def param_value_for param_name param = @params.detect{|p| p.name == param_name } param ? param.value : nil end
@return [Integer] Returns the port the request will be made over.
Defaults to 443 for SSL requests and 80 for non-SSL requests.
# File lib/aws/core/http/request.rb, line 89 def port @port || (use_ssl? ? 443 : 80) end
Override the default port (443 or 80). If you pass nil then the default port will take precedence. @param [Integer,nil] port_number
# File lib/aws/core/http/request.rb, line 83 def port= port_number @port = port_number end
@return [String, nil] Returns the requesty querystring.
# File lib/aws/core/http/request.rb, line 181 def querystring nil end
@return [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.
# File lib/aws/core/http/request.rb, line 115 def ssl_ca_file @ssl_ca_file end
@param [String] ca_file 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.
# File lib/aws/core/http/request.rb, line 108 def ssl_ca_file=(ca_file) @ssl_ca_file = ca_file end
@return [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.
# File lib/aws/core/http/request.rb, line 129 def ssl_ca_path @ssl_ca_path end
@param [String] ca_path 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.
# File lib/aws/core/http/request.rb, line 122 def ssl_ca_path=(ca_path) @ssl_ca_path = ca_path end
@param [Boolean] verify_peer If the client should verify the
peer certificate or not.
# File lib/aws/core/http/request.rb, line 95 def ssl_verify_peer=(verify_peer) @ssl_verify_peer = verify_peer end
@return [Boolean] If the client should verify the peer
certificate or not.
# File lib/aws/core/http/request.rb, line 101 def ssl_verify_peer? @ssl_verify_peer end
@return [String] the request uri
# File lib/aws/core/http/request.rb, line 166 def uri querystring ? "#{path}?#{querystring}" : path end
@return [String] Returns the request params url encoded, or nil if
this request has no params.
# File lib/aws/core/http/request.rb, line 172 def url_encoded_params if @params.empty? nil else @params.sort.collect{|p| p.encoded }.join('&') end end
@param [Boolean] ssl If the request should be sent over ssl or not.
# File lib/aws/core/http/request.rb, line 71 def use_ssl= use_ssl @use_ssl = use_ssl end
@return [Boolean] If this request should be sent over ssl or not.
# File lib/aws/core/http/request.rb, line 76 def use_ssl? @use_ssl end