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'
LHOST =
'host'.freeze
UHOST =
'Host'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ HTTPXHTTPRequest

Returns a new instance of HTTPXHTTPRequest.



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

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



87
88
89
# File 'lib/new_relic/agent/http_clients/httpx_wrappers.rb', line 87

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

#[]=(key, value) ⇒ Object



79
80
81
# File 'lib/new_relic/agent/http_clients/httpx_wrappers.rb', line 79

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

#headersObject



83
84
85
# File 'lib/new_relic/agent/http_clients/httpx_wrappers.rb', line 83

def headers
  @request.headers
end

#hostObject



71
72
73
# File 'lib/new_relic/agent/http_clients/httpx_wrappers.rb', line 71

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

#host_from_headerObject



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

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

#methodObject



75
76
77
# File 'lib/new_relic/agent/http_clients/httpx_wrappers.rb', line 75

def method
  @request.verb
end

#typeObject



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

def type
  TYPE
end