Class: AWS::Core::Http::Response
- Inherits:
-
Object
- Object
- AWS::Core::Http::Response
- Defined in:
- lib/aws/core/http/response.rb
Overview
Represents the http response from a service request.
Responses have:
-
status (200, 404, 500, etc)
-
headers (hash of response headers)
-
body (the response body)
Instance Attribute Summary collapse
-
#body ⇒ String
(”) response http body.
-
#headers ⇒ Hash
({}) response http headers.
-
#status ⇒ Integer
(200) response http status code.
-
#timeout ⇒ String
(also: #timeout?)
(false) set to true if the client gives up before getting a response from the service.
Instance Method Summary collapse
-
#header(name) ⇒ String?
Returns the header value with the given name.
-
#initialize(options = {}) {|_self| ... } ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ Response
Returns a new instance of Response.
45 46 47 48 49 50 51 |
# File 'lib/aws/core/http/response.rb', line 45 def initialize = {}, &block @status = [:status] || 200 @headers = [:headers] || {} @body = [:body] || '' yield(self) if block_given? self end |
Instance Attribute Details
#body ⇒ String
Returns (”) response http body.
34 35 36 |
# File 'lib/aws/core/http/response.rb', line 34 def body @body end |
#headers ⇒ Hash
Returns ({}) response http headers.
31 32 33 |
# File 'lib/aws/core/http/response.rb', line 31 def headers @headers end |
#status ⇒ Integer
Returns (200) response http status code.
28 29 30 |
# File 'lib/aws/core/http/response.rb', line 28 def status @status end |
#timeout ⇒ String Also known as: timeout?
Returns (false) set to true if the client gives up before getting a response from the service.
38 39 40 |
# File 'lib/aws/core/http/response.rb', line 38 def timeout @timeout end |
Instance Method Details
#header(name) ⇒ String?
Returns the header value with the given name.
The value is matched case-insensitively so if the headers hash contains a key like ‘Date’ and you request the value for ‘date’ the ‘Date’ value will be returned.
61 62 63 64 65 66 67 68 |
# File 'lib/aws/core/http/response.rb', line 61 def header name headers.each_pair do |header_name, header_value| if header_name.downcase == name.to_s.downcase return header_value.is_a?(Array) ? header_value.first : header_value end end nil end |