Class: NewRelic::Agent::HTTPClients::HTTPXHTTPRequest

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

Constant Summary collapse

DEFAULT_HOST =
'UNKNOWN_HOST'
TYPE =
'HTTPX'

Constants inherited from AbstractRequest

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ HTTPXHTTPRequest

Returns a new instance of HTTPXHTTPRequest.



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

def initialize(request)
  @request = request
  @uri = request.uri
end

Instance Attribute Details

#uriObject (readonly)

Returns the value of attribute uri.



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

def uri
  @uri
end

Instance Method Details

#[](key) ⇒ Object



85
86
87
# File 'lib/new_relic/agent/http_clients/httpx_wrappers.rb', line 85

def [](key)
  @request.headers[key]
end

#[]=(key, value) ⇒ Object



77
78
79
# File 'lib/new_relic/agent/http_clients/httpx_wrappers.rb', line 77

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

#headersObject



81
82
83
# File 'lib/new_relic/agent/http_clients/httpx_wrappers.rb', line 81

def headers
  @request.headers
end

#hostObject



69
70
71
# File 'lib/new_relic/agent/http_clients/httpx_wrappers.rb', line 69

def host
  host_from_header || uri.host&.downcase || DEFAULT_HOST
end

#host_from_headerObject



65
66
67
# File 'lib/new_relic/agent/http_clients/httpx_wrappers.rb', line 65

def host_from_header
  self[LHOST] || self[UHOST]
end

#methodObject



73
74
75
# File 'lib/new_relic/agent/http_clients/httpx_wrappers.rb', line 73

def method
  @request.verb
end

#typeObject



61
62
63
# File 'lib/new_relic/agent/http_clients/httpx_wrappers.rb', line 61

def type
  TYPE
end