class AWS::Core::Response

@private

Attributes

cached[RW]

@return [Boolean] true if the response is cached

duration[RW]

@return [Float] The total number of seconds taken to make the

request and return the response.
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
retry_count[RW]

@return [Integer] Returns the number of times the request

was retried.

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 54
def initialize http_request = nil, http_response = nil, &block
  @http_request = http_request
  @http_response = http_response
  @request_builder = block
  @retry_count = 0
  @duration = 0
  rebuild_request if @request_builder && !http_request
end

Public Instance Methods

cache_key() click to toggle source
# File lib/aws/core/response.rb, line 99
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 91
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 64
def rebuild_request
  @http_request = @request_builder.call
end
serialized_options() click to toggle source
# File lib/aws/core/response.rb, line 106
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 69
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 75
def throttled?
  if !successful? and http_response.body
    error = XmlGrammar.parse(http_response.body)
    error = error.error if error.respond_to?(:error)
    error.respond_to?(:code) and error.code == "Throttling"
  else
    false
  end
end
timeout?() click to toggle source

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

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