Class: NewRelic::Agent::HTTPClients::HTTPXHTTPResponse
- Inherits:
-
AbstractResponse
- Object
- AbstractResponse
- NewRelic::Agent::HTTPClients::HTTPXHTTPResponse
- Defined in:
- lib/new_relic/agent/http_clients/httpx_wrappers.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #headers ⇒ Object (also: #to_hash)
-
#initialize(response) ⇒ HTTPXHTTPResponse
constructor
A new instance of HTTPXHTTPResponse.
- #status_code ⇒ Object
Methods inherited from AbstractResponse
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 |
#headers ⇒ Object 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_code ⇒ Object
28 29 30 |
# File 'lib/new_relic/agent/http_clients/httpx_wrappers.rb', line 28 def status_code @response.status end |