Class: NewRelic::Agent::HTTPClients::EthonHTTPResponse

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

Instance Method Summary collapse

Methods inherited from AbstractResponse

#has_status_code?

Constructor Details

#initialize(easy) ⇒ EthonHTTPResponse

Returns a new instance of EthonHTTPResponse.



12
13
14
# File 'lib/new_relic/agent/http_clients/ethon_wrappers.rb', line 12

def initialize(easy)
  @easy = easy
end

Instance Method Details

#[](key) ⇒ Object



20
21
22
# File 'lib/new_relic/agent/http_clients/ethon_wrappers.rb', line 20

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

#headersObject Also known as: to_hash



24
25
26
27
28
29
# File 'lib/new_relic/agent/http_clients/ethon_wrappers.rb', line 24

def headers
  # Ethon::Easy#response_headers will return '' if headers are unset
  @easy.response_headers.scan(/\n([^:]+?): ([^:\n]+?)\r/).each_with_object({}) do |pair, hash|
    hash[format_key(pair[0])] = pair[1]
  end
end

#status_codeObject



16
17
18
# File 'lib/new_relic/agent/http_clients/ethon_wrappers.rb', line 16

def status_code
  @easy.response_code
end