class AWS::Core::Http::Request

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.

Attributes

access_key_id[RW]

@return [String] the AWS access key ID used to authorize the

request
headers[RW]

@return [CaseInsensitiveHash] request headers

host[RW]

@return [String] hostname of the request

http_method[RW]

@return [String] GET, PUT POST, HEAD or DELETE, defaults to POST

params[RW]

@return [Array] An array of request params, each param responds to

#name and #value.
path[RW]

@return [String] path of the request URI, defaults to /

proxy_uri[RW]

@return [nil, URI] The URI to the proxy server requests are

sent through if configured.  Returns nil if there is no proxy.
read_timeout[RW]

@return [Integer] The number of seconds the service has to respond

before a timeout error is raised on the request.  Defaults to 
60 seconds.
region[RW]

@return [String] The region name this request is for. Only needs

to be populated for requests against signature v4 endpoints.
service_ruby_name[RW]

@return [String] The snake-cased ruby name for the service

(e.g. 's3', 'iam', 'dynamo_db', etc).

Public Class Methods

new() click to toggle source

Returns a new empty http request object.

# 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
  @read_timeout = 60 
end

Public Instance Methods

[]=(name_or_param, value = nil) click to toggle source
Alias for: add_param
add_param(name_or_param, value = nil) click to toggle source

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 147
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
Also aliased as: []=
body() click to toggle source

@return [String, nil] Returns the request body.

# File lib/aws/core/http/request.rb, line 189
def body
  url_encoded_params
end
get_param(param_name) click to toggle source

@private

# File lib/aws/core/http/request.rb, line 157
def get_param param_name
  @params.detect{|p| p.name == param_name } ||
    raise("undefined param #{param_name}")
end
param_value_for(param_name) click to toggle source

@private

# File lib/aws/core/http/request.rb, line 163
def param_value_for param_name
  param = @params.detect{|p| p.name == param_name }
  param ? param.value : nil
end
port() click to toggle source

@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 92
def port
  @port || (use_ssl? ? 443 : 80)
end
port=(port_number) click to toggle source

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 86
def port= port_number
  @port = port_number
end
querystring() click to toggle source

@return [String, nil] Returns the requesty querystring.

# File lib/aws/core/http/request.rb, line 184
def querystring
  nil
end
ssl_ca_file() click to toggle source

@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 118
def ssl_ca_file
  @ssl_ca_file
end
ssl_ca_file=(ca_file) click to toggle source

@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 111
def ssl_ca_file=(ca_file)
  @ssl_ca_file = ca_file
end
ssl_ca_path() click to toggle source

@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 132
def ssl_ca_path
  @ssl_ca_path
end
ssl_ca_path=(ca_path) click to toggle source

@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 125
def ssl_ca_path=(ca_path)
  @ssl_ca_path = ca_path
end
ssl_verify_peer=(verify_peer) click to toggle source

@param [Boolean] verify_peer If the client should verify the

peer certificate or not.
# File lib/aws/core/http/request.rb, line 98
def ssl_verify_peer=(verify_peer)
  @ssl_verify_peer = verify_peer
end
ssl_verify_peer?() click to toggle source

@return [Boolean] If the client should verify the peer

certificate or not.
# File lib/aws/core/http/request.rb, line 104
def ssl_verify_peer?
  @ssl_verify_peer
end
uri() click to toggle source

@return [String] the request uri

# File lib/aws/core/http/request.rb, line 169
def uri
  querystring ? "#{path}?#{querystring}" : path
end
url_encoded_params() click to toggle source

@return [String] Returns the request params url encoded, or nil if

this request has no params.
# File lib/aws/core/http/request.rb, line 175
def url_encoded_params
  if @params.empty?
    nil
  else
    @params.sort.collect{|p| p.encoded }.join('&')
  end
end
use_ssl=(state) click to toggle source

@param [Boolean] state If the request should be sent over ssl or not.

# File lib/aws/core/http/request.rb, line 74
def use_ssl= state
  @use_ssl = state
end
use_ssl?() click to toggle source

@return [Boolean] If this request should be sent over ssl or not.

# File lib/aws/core/http/request.rb, line 79
def use_ssl?
  @use_ssl
end