Class: NewRelic::Agent::HTTPClients::HTTPXHTTPResponse

Inherits:
AbstractResponse show all
Defined in:
lib/new_relic/agent/http_clients/httpx_wrappers.rb

Instance Method Summary collapse

Methods inherited from AbstractResponse

#has_status_code?

Constructor Details

#initialize(response) ⇒ HTTPXHTTPResponse

Returns a new instance of HTTPXHTTPResponse.



20
21
22
23
24
25
26
# File 'lib/new_relic/agent/http_clients/httpx_wrappers.rb', line 20

def initialize(response)
  if response.is_a?(::HTTPX::ErrorResponse)
    @response = response.response || HTTPXErrorResponse.new
  else
    @response = response
  end
end

Instance Method Details

#[](key) ⇒ Object



32
33
34
# File 'lib/new_relic/agent/http_clients/httpx_wrappers.rb', line 32

def [](key)
  headers[format_key(key)]
end

#headersObject Also known as: to_hash



36
37
38
39
40
# File 'lib/new_relic/agent/http_clients/httpx_wrappers.rb', line 36

def headers
  headers ||= @response.headers.to_hash.each_with_object({}) do |(k, v), h|
    h[format_key(k)] = v
  end
end

#status_codeObject



28
29
30
# File 'lib/new_relic/agent/http_clients/httpx_wrappers.rb', line 28

def status_code
  @response.status
end