class AWS::Core::Http::Response

Represents the http response from a service request.

Responses have:

Attributes

body[RW]

@return [String,nil] Returns the HTTP response body.

headers[RW]

@return [Hash] ({}) Returns the HTTP response headers.

network_error[RW]

@return [Exception,nil]

status[RW]

@return [Integer] Returns the http response status code.

timeout=[RW]

@return [Exception,nil]

Public Class Methods

new(options = {}) { |self| ... } click to toggle source

@param [Hash] options @option options [Integer] :status (200) HTTP status code @option options [Hash] :headers ({}) HTTP response headers @option options [String] :body ('') HTTP response body

# File lib/aws/core/http/response.rb, line 53
def initialize options = {}, &block
  @status = options[:status] || 200
  @headers = options[:headers] || {}
  @body = options[:body]
  yield(self) if block_given?
  self
end

Public Instance Methods

header(name) click to toggle source

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.

@param [String,Symbol] name The name of the header to fetch a value for. @return [String,nil] The value of the given header

# File lib/aws/core/http/response.rb, line 69
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
network_error?() click to toggle source

@return [Boolean] Returns `true` if the request could not be made

because of a networking issue (including timeouts).
# File lib/aws/core/http/response.rb, line 41
def network_error?
  @network_error ? true : false
end