class NewRelic::Agent::HTTPClients::EthonHTTPResponse

Public Class Methods

new(easy) click to toggle source
# File lib/new_relic/agent/http_clients/ethon_wrappers.rb, line 12
def initialize(easy)
  @easy = easy
end

Public Instance Methods

[](key) click to toggle source
# File lib/new_relic/agent/http_clients/ethon_wrappers.rb, line 20
def [](key)
  headers[format_key(key)]
end
headers() click to toggle source
# 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
Also aliased as: to_hash
status_code() click to toggle source
# File lib/new_relic/agent/http_clients/ethon_wrappers.rb, line 16
def status_code
  @easy.response_code
end
to_hash()
Alias for: headers

Private Instance Methods

format_key(key) click to toggle source
# File lib/new_relic/agent/http_clients/ethon_wrappers.rb, line 34
def format_key(key)
  key.tr('-', '_').downcase
end