class AWS::Core::Http::Request

Base class for all service reqeusts.

Attributes

access_key_id[RW]

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

request
headers[R]

@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[R]

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

#name and #value.
path[R]

@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.

Public Class Methods

new() click to toggle source

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

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

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

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

@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
param_value_for(param_name) click to toggle source

@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
querystring() click to toggle source

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

# File lib/aws/core/http/request.rb, line 159
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 93
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 86
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 107
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 100
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 73
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 79
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 144
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 150
def url_encoded_params
  if @params.empty?
    nil
  else
    @params.sort.collect{|p| p.encoded }.join('&')
  end
end
use_ssl=(use_ssl) click to toggle source

@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
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 67
def use_ssl?
  @use_ssl
end