Class: Aws::Rest::Response::Headers Private
- Inherits:
-
Object
- Object
- Aws::Rest::Response::Headers
- Includes:
- Seahorse::Model::Shapes
- Defined in:
- lib/aws-sdk-core/rest/response/headers.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #apply(http_resp, target) ⇒ Object private
- #cast_value(ref, value) ⇒ Object private
- #extract_header_map(headers, name, ref, data) ⇒ Object private
- #extract_header_value(headers, name, ref, data) ⇒ Object private
-
#initialize(rules) ⇒ Headers
constructor
private
A new instance of Headers.
Constructor Details
#initialize(rules) ⇒ Headers
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Headers.
9 10 11 |
# File 'lib/aws-sdk-core/rest/response/headers.rb', line 9 def initialize(rules) @rules = rules end |
Instance Method Details
#apply(http_resp, target) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 18 19 20 21 22 23 |
# File 'lib/aws-sdk-core/rest/response/headers.rb', line 15 def apply(http_resp, target) headers = http_resp.headers @rules.shape.members.each do |name, ref| case ref.location when 'header' then extract_header_value(headers, name, ref, target) when 'headers' then extract_header_map(headers, name, ref, target) end end end |
#cast_value(ref, value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/aws-sdk-core/rest/response/headers.rb', line 31 def cast_value(ref, value) case ref.shape when StringShape then value when IntegerShape then value.to_i when FloatShape then value.to_f when BooleanShape then value == 'true' when TimestampShape if value =~ /\d+(\.\d*)/ Time.at(value.to_f) else Time.parse(value) end else raise "unsupported shape #{ref.shape.class}" end end |
#extract_header_map(headers, name, ref, data) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
47 48 49 50 51 52 53 54 55 |
# File 'lib/aws-sdk-core/rest/response/headers.rb', line 47 def extract_header_map(headers, name, ref, data) data[name] = {} prefix = ref.location_name || '' headers.each do |header_name, header_value| if match = header_name.match(/^#{prefix}(.+)/i) data[name][match[1]] = header_value end end end |
#extract_header_value(headers, name, ref, data) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 28 29 |
# File 'lib/aws-sdk-core/rest/response/headers.rb', line 25 def extract_header_value(headers, name, ref, data) if headers.key?(ref.location_name) data[name] = cast_value(ref, headers[ref.location_name]) end end |