Class: OneApm::Support::HTTPClients::ExconHTTPResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/one_apm/support/http_clients/excon_wrappers.rb

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ ExconHTTPResponse

Returns a new instance of ExconHTTPResponse.



7
8
9
10
11
12
13
14
15
16
# File 'lib/one_apm/support/http_clients/excon_wrappers.rb', line 7

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



18
19
20
# File 'lib/one_apm/support/http_clients/excon_wrappers.rb', line 18

def [](key)
  @normalized_headers[key.upcase]
end

#to_hashObject



22
23
24
# File 'lib/one_apm/support/http_clients/excon_wrappers.rb', line 22

def to_hash
  @normalized_headers.dup
end