Class: NewRelic::Agent::HTTPClients::HTTPClientRequest
- Inherits:
-
AbstractRequest
- Object
- AbstractRequest
- NewRelic::Agent::HTTPClients::HTTPClientRequest
- 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
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #headers ⇒ Object
- #host ⇒ Object
- #host_from_header ⇒ Object
-
#initialize(request) ⇒ HTTPClientRequest
constructor
A new instance of HTTPClientRequest.
- #method ⇒ Object
- #type ⇒ Object
- #uri ⇒ Object
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
#request ⇒ Object (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 |
#headers ⇒ Object
67 68 69 |
# File 'lib/new_relic/agent/http_clients/httpclient_wrappers.rb', line 67 def headers request.headers end |
#host ⇒ Object
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_header ⇒ Object
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 |
#method ⇒ Object
41 42 43 |
# File 'lib/new_relic/agent/http_clients/httpclient_wrappers.rb', line 41 def method request.header.request_method end |
#type ⇒ Object
37 38 39 |
# File 'lib/new_relic/agent/http_clients/httpclient_wrappers.rb', line 37 def type HTTP_CLIENT end |
#uri ⇒ Object
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 |