Class: AWS::Core::RESTResponseParser

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

Overview

Given a hash of request options, a REST::RequestHandler can populate a Core::Http::Request object.

Instance Method Summary collapse

Instance Method Details

#extract_data(response) ⇒ Hash

Given a response object, this method extract and returns a hash of response data.

Parameters:

Returns:

  • (Hash)


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/aws/core/rest_response_parser.rb', line 36

def extract_data response

  if payload = @http[:response_payload]
    data = { payload => response.http_response.body }
  else
    data = @parser.parse(response.http_response.body)
  end

  if header = response.http_response.headers['x-amzn-requestid']
    data[:request_id] = [header].flatten.first
  end

  # extract headers and insert into response
  (@http[:response_headers] || {}).each_pair do |name,header_name|
    if header = response.http_response.headers[header_name.downcase]
      data[name] = [header].flatten.first
    end
  end

  data

end

#simulateObject



59
60
61
# File 'lib/aws/core/rest_response_parser.rb', line 59

def simulate
  {}
end