Class: NewRelic::Agent::HTTPClients::AsyncHTTPRequest
- Inherits:
-
AbstractRequest
- Object
- AbstractRequest
- NewRelic::Agent::HTTPClients::AsyncHTTPRequest
- Defined in:
- lib/new_relic/agent/http_clients/async_http_wrappers.rb
Constant Summary collapse
- ASYNC_HTTP =
'Async::HTTP'
- LHOST =
'host'
- UHOST =
'Host'
- COLON =
':'
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #headers ⇒ Object
- #host ⇒ Object
- #host_from_header ⇒ Object
-
#initialize(connection, method, url, headers) ⇒ AsyncHTTPRequest
constructor
A new instance of AsyncHTTPRequest.
- #method ⇒ Object
- #type ⇒ Object
- #uri ⇒ Object
Constructor Details
#initialize(connection, method, url, headers) ⇒ AsyncHTTPRequest
Returns a new instance of AsyncHTTPRequest.
26 27 28 29 30 31 |
# File 'lib/new_relic/agent/http_clients/async_http_wrappers.rb', line 26 def initialize(connection, method, url, headers) @connection = connection @method = method @url = ::NewRelic::Agent::HTTPClients::URIUtil.parse_and_normalize_url(url) @headers = headers end |
Instance Method Details
#[](key) ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/new_relic/agent/http_clients/async_http_wrappers.rb', line 52 def [](key) return headers[key] unless headers.is_a?(Array) headers.each do |header| return header[1] if header[0].casecmp?(key) end nil end |
#[]=(key, value) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/new_relic/agent/http_clients/async_http_wrappers.rb', line 61 def []=(key, value) if headers.is_a?(Array) headers << [key, value] else headers[key] = value end end |
#headers ⇒ Object
73 74 75 |
# File 'lib/new_relic/agent/http_clients/async_http_wrappers.rb', line 73 def headers @headers end |
#host ⇒ Object
48 49 50 |
# File 'lib/new_relic/agent/http_clients/async_http_wrappers.rb', line 48 def host host_from_header || uri.host.to_s end |
#host_from_header ⇒ Object
42 43 44 45 46 |
# File 'lib/new_relic/agent/http_clients/async_http_wrappers.rb', line 42 def host_from_header if hostname = (self[LHOST] || self[UHOST]) hostname.split(COLON).first end end |
#method ⇒ Object
77 78 79 |
# File 'lib/new_relic/agent/http_clients/async_http_wrappers.rb', line 77 def method @method end |
#type ⇒ Object
38 39 40 |
# File 'lib/new_relic/agent/http_clients/async_http_wrappers.rb', line 38 def type ASYNC_HTTP end |
#uri ⇒ Object
69 70 71 |
# File 'lib/new_relic/agent/http_clients/async_http_wrappers.rb', line 69 def uri @url end |