class NewRelic::Agent::HTTPClients::NetHTTPRequest

Constants

NET_HTTP

Public Class Methods

new(connection, request) click to toggle source
# File lib/new_relic/agent/http_clients/net_http_wrappers.rb, line 22
def initialize(connection, request)
  @connection = connection
  @request = request
end

Public Instance Methods

[](key) click to toggle source
# File lib/new_relic/agent/http_clients/net_http_wrappers.rb, line 47
def [](key)
  @request[key]
end
[]=(key, value) click to toggle source
# File lib/new_relic/agent/http_clients/net_http_wrappers.rb, line 51
def []=(key, value)
  @request[key] = value
end
headers() click to toggle source
# File lib/new_relic/agent/http_clients/net_http_wrappers.rb, line 72
def headers
  @request.instance_variable_get(:@header)
end
host() click to toggle source
# File lib/new_relic/agent/http_clients/net_http_wrappers.rb, line 39
def host
  host_from_header || @connection.address
end
host_from_header() click to toggle source
# File lib/new_relic/agent/http_clients/net_http_wrappers.rb, line 33
def host_from_header
  if hostname = self[LHOST]
    hostname.split(COLON).first
  end
end
method() click to toggle source
# File lib/new_relic/agent/http_clients/net_http_wrappers.rb, line 43
def method
  @request.method
end
type() click to toggle source
# File lib/new_relic/agent/http_clients/net_http_wrappers.rb, line 29
def type
  NET_HTTP
end
uri() click to toggle source
# File lib/new_relic/agent/http_clients/net_http_wrappers.rb, line 55
def uri
  case @request.path
  when /^https?:\/\//
    ::NewRelic::Agent::HTTPClients::URIUtil.parse_and_normalize_url(@request.path)
  else
    connection_address = @connection.address
    if Resolv::IPv6::Regex.match?(connection_address)
      connection_address = "[#{connection_address}]"
    end

    scheme = @connection.use_ssl? ? 'https' : 'http'
    ::NewRelic::Agent::HTTPClients::URIUtil.parse_and_normalize_url(
      "#{scheme}://#{connection_address}:#{@connection.port}#{@request.path}"
    )
  end
end