Class: AWS::Core::Http::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/core/http/request.rb

Overview

Base class for all service reqeusts.

Direct Known Subclasses

DynamoDB::Request, SimpleWorkflow::Request

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRequest

Returns a new empty http request object.



22
23
24
25
26
27
28
29
30
31
# 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

Instance Attribute Details

#access_key_idString

Returns the AWS access key ID used to authorize the request.

Returns:

  • (String)

    the AWS access key ID used to authorize the request



60
61
62
# File 'lib/aws/core/http/request.rb', line 60

def access_key_id
  @access_key_id
end

#headersCaseInsensitiveHash

Returns request headers.

Returns:

  • (CaseInsensitiveHash)

    request headers



46
47
48
# File 'lib/aws/core/http/request.rb', line 46

def headers
  @headers
end

#hostString

Returns hostname of the request.

Returns:

  • (String)

    hostname of the request



43
44
45
# File 'lib/aws/core/http/request.rb', line 43

def host
  @host
end

#http_methodString

Returns GET, PUT POST, HEAD or DELETE, defaults to POST.

Returns:

  • (String)

    GET, PUT POST, HEAD or DELETE, defaults to POST



53
54
55
# File 'lib/aws/core/http/request.rb', line 53

def http_method
  @http_method
end

#paramsArray

Returns An array of request params, each param responds to #name and #value.

Returns:

  • (Array)

    An array of request params, each param responds to #name and #value.



50
51
52
# File 'lib/aws/core/http/request.rb', line 50

def params
  @params
end

#pathString

Returns path of the request URI, defaults to /.

Returns:

  • (String)

    path of the request URI, defaults to /



56
57
58
# File 'lib/aws/core/http/request.rb', line 56

def path
  @path
end

#proxy_urinil, URI

Returns The URI to the proxy server requests are sent through if configured. Returns nil if there is no proxy.

Returns:

  • (nil, URI)

    The URI to the proxy server requests are sent through if configured. Returns nil if there is no proxy.



64
65
66
# File 'lib/aws/core/http/request.rb', line 64

def proxy_uri
  @proxy_uri
end

#read_timeoutInteger

Returns The number of seconds the service has to respond before a timeout error is raised on the request. Defaults to 60 seconds.

Returns:

  • (Integer)

    The number of seconds the service has to respond before a timeout error is raised on the request. Defaults to 60 seconds.



36
37
38
# File 'lib/aws/core/http/request.rb', line 36

def read_timeout
  @read_timeout
end

#regionString

Returns The region name this request is for. Only needs to be populated for requests against signature v4 endpoints.

Returns:

  • (String)

    The region name this request is for. Only needs to be populated for requests against signature v4 endpoints.



68
69
70
# File 'lib/aws/core/http/request.rb', line 68

def region
  @region
end

#service_ruby_nameString

Returns The snake-cased ruby name for the service (e.g. ‘s3’, ‘iam’, ‘dynamo_db’, etc).

Returns:

  • (String)

    The snake-cased ruby name for the service (e.g. ‘s3’, ‘iam’, ‘dynamo_db’, etc).



40
41
42
# File 'lib/aws/core/http/request.rb', line 40

def service_ruby_name
  @service_ruby_name
end

Instance Method Details

#add_param(param_name, param_value = nil) ⇒ Object #add_param(param_obj) ⇒ Object Also known as: []=

Adds a request param.

Overloads:

  • #add_param(param_name, param_value = nil) ⇒ Object

    Add a param (name/value)

    Parameters:

    • param_name (String)
    • param_value (String) (defaults to: nil)

      Leave blank for sub resources

  • #add_param(param_obj) ⇒ Object

    Add a param (object)

    Parameters:

    • param_obj (Param)


144
145
146
147
148
149
150
# 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

#bodyString?

Returns the request body.

Returns:

  • (String, nil)

    Returns the request body.



186
187
188
# File 'lib/aws/core/http/request.rb', line 186

def body
  url_encoded_params
end

#portInteger

Returns the port the request will be made over. Defaults to 443 for SSL requests and 80 for non-SSL requests.

Returns:

  • (Integer)

    Returns the port the request will be made over. Defaults to 443 for SSL requests and 80 for non-SSL requests.



89
90
91
# File 'lib/aws/core/http/request.rb', line 89

def port
  @port || (use_ssl? ? 443 : 80)
end

#port=(port_number) ⇒ Object

Override the default port (443 or 80). If you pass nil then the default port will take precedence.

Parameters:

  • port_number (Integer, nil)


83
84
85
# File 'lib/aws/core/http/request.rb', line 83

def port= port_number
  @port = port_number
end

#querystringString?

Returns the requesty querystring.

Returns:

  • (String, nil)

    Returns the requesty querystring.



181
182
183
# File 'lib/aws/core/http/request.rb', line 181

def querystring
  nil
end

#ssl_ca_fileString

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.

Returns:

  • (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.



115
116
117
# File 'lib/aws/core/http/request.rb', line 115

def ssl_ca_file
  @ssl_ca_file
end

#ssl_ca_file=(ca_file) ⇒ Object

Parameters:

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



108
109
110
# File 'lib/aws/core/http/request.rb', line 108

def ssl_ca_file=(ca_file)
  @ssl_ca_file = ca_file
end

#ssl_ca_pathString

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.

Returns:

  • (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.



129
130
131
# File 'lib/aws/core/http/request.rb', line 129

def ssl_ca_path
  @ssl_ca_path
end

#ssl_ca_path=(ca_path) ⇒ Object

Parameters:

  • ca_path (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.



122
123
124
# File 'lib/aws/core/http/request.rb', line 122

def ssl_ca_path=(ca_path)
  @ssl_ca_path = ca_path
end

#ssl_verify_peer=(verify_peer) ⇒ Object

Parameters:

  • verify_peer (Boolean)

    If the client should verify the peer certificate or not.



95
96
97
# File 'lib/aws/core/http/request.rb', line 95

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.

Returns:

  • (Boolean)

    If the client should verify the peer certificate or not.



101
102
103
# File 'lib/aws/core/http/request.rb', line 101

def ssl_verify_peer?
  @ssl_verify_peer
end

#uriString

Returns the request uri.

Returns:

  • (String)

    the request uri



166
167
168
# File 'lib/aws/core/http/request.rb', line 166

def uri
  querystring ? "#{path}?#{querystring}" : path
end

#url_encoded_paramsString

Returns the request params url encoded, or nil if this request has no params.

Returns:

  • (String)

    Returns the request params url encoded, or nil if this request has no params.



172
173
174
175
176
177
178
# 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

#use_ssl=(use_ssl) ⇒ Object

Parameters:

  • ssl (Boolean)

    If the request should be sent over ssl or not.



71
72
73
# File 'lib/aws/core/http/request.rb', line 71

def use_ssl= use_ssl
  @use_ssl = use_ssl
end

#use_ssl?Boolean

Returns If this request should be sent over ssl or not.

Returns:

  • (Boolean)

    If this request should be sent over ssl or not.



76
77
78
# File 'lib/aws/core/http/request.rb', line 76

def use_ssl?
  @use_ssl
end