Class: TingYun::Http::ExconHTTPResponse
- Inherits:
-
Object
- Object
- TingYun::Http::ExconHTTPResponse
- Defined in:
- lib/ting_yun/http/excon_wrappers.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(response) ⇒ ExconHTTPResponse
constructor
A new instance of ExconHTTPResponse.
- #to_hash ⇒ Object
Constructor Details
#initialize(response) ⇒ ExconHTTPResponse
Returns a new instance of ExconHTTPResponse.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/ting_yun/http/excon_wrappers.rb', line 9 def initialize(response) @response = response # Since HTTP headers are case-insensitive, we normalize all of them to # upper case here, and then also in our [](key) implementation. @normalized_headers = {} headers = response.respond_to?(:headers) ? response.headers : response[:headers] (headers || {}).each do |key, val| @normalized_headers[key.upcase] = val end end |
Instance Method Details
#[](key) ⇒ Object
21 22 23 |
# File 'lib/ting_yun/http/excon_wrappers.rb', line 21 def [](key) @normalized_headers[key.upcase] end |
#to_hash ⇒ Object
25 26 27 |
# File 'lib/ting_yun/http/excon_wrappers.rb', line 25 def to_hash @normalized_headers.dup end |