Class: NewRelic::Agent::HTTPClients::TyphoeusHTTPRequest
- Inherits:
-
AbstractRequest
- Object
- AbstractRequest
- NewRelic::Agent::HTTPClients::TyphoeusHTTPRequest
- Defined in:
- lib/new_relic/agent/http_clients/typhoeus_wrappers.rb
Constant Summary collapse
- TYPHOEUS =
'Typhoeus'.freeze
- LHOST =
'host'.freeze
- UHOST =
'Host'.freeze
- GET =
'GET'.freeze
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #headers ⇒ Object
- #host ⇒ Object
- #host_from_header ⇒ Object
-
#initialize(request) ⇒ TyphoeusHTTPRequest
constructor
A new instance of TyphoeusHTTPRequest.
- #method ⇒ Object
- #type ⇒ Object
- #uri ⇒ Object
Constructor Details
#initialize(request) ⇒ TyphoeusHTTPRequest
Returns a new instance of TyphoeusHTTPRequest.
37 38 39 40 41 42 43 |
# File 'lib/new_relic/agent/http_clients/typhoeus_wrappers.rb', line 37 def initialize(request) @request = request @uri = case request.url when ::URI then request.url else NewRelic::Agent::HTTPClients::URIUtil.parse_and_normalize_url(request.url) end end |
Instance Method Details
#[](key) ⇒ Object
68 69 70 71 72 |
# File 'lib/new_relic/agent/http_clients/typhoeus_wrappers.rb', line 68 def [](key) return nil unless @request. && headers headers[key] end |
#[]=(key, value) ⇒ Object
74 75 76 |
# File 'lib/new_relic/agent/http_clients/typhoeus_wrappers.rb', line 74 def []=(key, value) headers[key] = value end |
#headers ⇒ Object
78 79 80 |
# File 'lib/new_relic/agent/http_clients/typhoeus_wrappers.rb', line 78 def headers @request.[:headers] || {} end |
#host ⇒ Object
58 59 60 |
# File 'lib/new_relic/agent/http_clients/typhoeus_wrappers.rb', line 58 def host host_from_header || @uri.host end |
#host_from_header ⇒ Object
54 55 56 |
# File 'lib/new_relic/agent/http_clients/typhoeus_wrappers.rb', line 54 def host_from_header self[LHOST] || self[UHOST] end |
#method ⇒ Object
64 65 66 |
# File 'lib/new_relic/agent/http_clients/typhoeus_wrappers.rb', line 64 def method (@request.[:method] || GET).to_s.upcase end |
#type ⇒ Object
47 48 49 |
# File 'lib/new_relic/agent/http_clients/typhoeus_wrappers.rb', line 47 def type TYPHOEUS end |
#uri ⇒ Object
82 83 84 |
# File 'lib/new_relic/agent/http_clients/typhoeus_wrappers.rb', line 82 def uri @uri end |