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.
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 @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 122 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 164 def body url_encoded_params end
@private
# File lib/aws/core/http/request.rb, line 132 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 138 def param_value_for param_name param = @params.detect{|p| p.name == param_name } param ? param.value : nil end
@return [String, nil] Returns the requesty querystring.
# File lib/aws/core/http/request.rb, line 159 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 93 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 86 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 107 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 100 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 73 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 79 def ssl_verify_peer? @ssl_verify_peer end
@return [String] the request uri
# File lib/aws/core/http/request.rb, line 144 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 150 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 62 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 67 def use_ssl? @use_ssl end