Class: NewRelic::Agent::HTTPClients::HTTPClientRequest

Inherits:
AbstractRequest show all
Defined in:
lib/new_relic/agent/http_clients/httpclient_wrappers.rb

Constant Summary collapse

HTTP_CLIENT =
'HTTPClient'.freeze
LHOST =
'host'.freeze
UHOST =
'Host'.freeze
COLON =
':'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ HTTPClientRequest

Returns a new instance of HTTPClientRequest.



33
34
35
# File 'lib/new_relic/agent/http_clients/httpclient_wrappers.rb', line 33

def initialize(request)
  @request = request
end

Instance Attribute Details

#requestObject (readonly)

Returns the value of attribute request.



26
27
28
# File 'lib/new_relic/agent/http_clients/httpclient_wrappers.rb', line 26

def request
  @request
end

Instance Method Details

#[](key) ⇒ Object



59
60
61
# File 'lib/new_relic/agent/http_clients/httpclient_wrappers.rb', line 59

def [](key)
  headers[key]
end

#[]=(key, value) ⇒ Object



63
64
65
# File 'lib/new_relic/agent/http_clients/httpclient_wrappers.rb', line 63

def []=(key, value)
  request.http_header[key] = value
end

#headersObject



67
68
69
# File 'lib/new_relic/agent/http_clients/httpclient_wrappers.rb', line 67

def headers
  request.headers
end

#hostObject



51
52
53
# File 'lib/new_relic/agent/http_clients/httpclient_wrappers.rb', line 51

def host
  host_from_header || uri.host.to_s
end

#host_from_headerObject



45
46
47
48
49
# File 'lib/new_relic/agent/http_clients/httpclient_wrappers.rb', line 45

def host_from_header
  if hostname = (self[LHOST] || self[UHOST])
    hostname.split(COLON).first
  end
end

#methodObject



41
42
43
# File 'lib/new_relic/agent/http_clients/httpclient_wrappers.rb', line 41

def method
  request.header.request_method
end

#typeObject



37
38
39
# File 'lib/new_relic/agent/http_clients/httpclient_wrappers.rb', line 37

def type
  HTTP_CLIENT
end

#uriObject



55
56
57
# File 'lib/new_relic/agent/http_clients/httpclient_wrappers.rb', line 55

def uri
  @uri ||= URIUtil.parse_and_normalize_url(request.header.request_uri)
end