Class: TingYun::Http::ExconHTTPResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/ting_yun/http/excon_wrappers.rb

Instance Method Summary collapse

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_hashObject



25
26
27
# File 'lib/ting_yun/http/excon_wrappers.rb', line 25

def to_hash
  @normalized_headers.dup
end