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

Constants inherited from AbstractRequest

AbstractRequest::COLON, AbstractRequest::LHOST, AbstractRequest::UHOST

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ HTTPClientRequest

Returns a new instance of HTTPClientRequest.



30
31
32
# File 'lib/new_relic/agent/http_clients/httpclient_wrappers.rb', line 30

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



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

def [](key)
  headers[key]
end

#[]=(key, value) ⇒ Object



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

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

#headersObject



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

def headers
  request.headers
end

#hostObject



48
49
50
# File 'lib/new_relic/agent/http_clients/httpclient_wrappers.rb', line 48

def host
  host_from_header || uri.host.to_s
end

#host_from_headerObject



42
43
44
45
46
# File 'lib/new_relic/agent/http_clients/httpclient_wrappers.rb', line 42

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

#methodObject



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

def method
  request.header.request_method
end

#typeObject



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

def type
  HTTP_CLIENT
end

#uriObject



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

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