class AWS::Core::Response

@private

Attributes

cached[RW]

@return [Boolean] true if the response is cached

error[RW]

@return [AWS::Error] Returns nil unless the request failed.

Normally this will be nil unless you are using the Asynchronous 
interface.
http_request[RW]

@return [Http::Request] the HTTP request object

http_response[RW]

@return [Http::Response] the HTTP response object

request_options[RW]

@return [Hash] The hash of options passed to the low level request

method that generated this response.
request_type[RW]

@return [Symbol] The low-level request method that generated

this response

Public Class Methods

new(http_request = nil, http_response = nil, &block) click to toggle source

@param [Http::Request] #http_request @param [Http::Response] #http_request

# File lib/aws/core/response.rb, line 46
def initialize http_request = nil, http_response = nil, &block
  @http_request = http_request
  @http_response = http_response
  @request_builder = block
  rebuild_request if @request_builder && !http_request
end

Public Instance Methods

cache_key() click to toggle source
# File lib/aws/core/response.rb, line 87
def cache_key
  [http_request.access_key_id,
   http_request.host,
   request_type,
   serialized_options].join(":")
end
inspect() click to toggle source

@private

# File lib/aws/core/response.rb, line 79
def inspect
  if request_type
    "<#{self.class}:#{request_type}>"
  else
    "<#{self.class}>"
  end
end
rebuild_request() click to toggle source

Rebuilds the HTTP request using the block passed to the initializer

# File lib/aws/core/response.rb, line 54
def rebuild_request
  @http_request = @request_builder.call
end
serialized_options() click to toggle source
# File lib/aws/core/response.rb, line 94
def serialized_options
  serialize_options_hash(request_options)
end
successful?() click to toggle source

@return [Boolean] Returns true unless there is a response error.

# File lib/aws/core/response.rb, line 59
def successful?
  error.nil?
end
throttled?() click to toggle source

@return [Boolean] Returns true if the http request was throttled

by AWS.
# File lib/aws/core/response.rb, line 65
def throttled?
  !successful? and
    http_response.body and
    parsed_body = XmlGrammar.parse(http_response.body) and
    parsed_body.respond_to?(:code) and
    parsed_body.code == "Throttling"
end
timeout?() click to toggle source

@return [Boolean] Returns true if the http request timed out.

# File lib/aws/core/response.rb, line 74
def timeout?
  http_response.timeout?
end