Class: NewRelic::Agent::HTTPClients::NetHTTPRequest
- Inherits:
-
AbstractRequest
- Object
- AbstractRequest
- NewRelic::Agent::HTTPClients::NetHTTPRequest
- Defined in:
- lib/new_relic/agent/http_clients/net_http_wrappers.rb
Constant Summary collapse
- NET_HTTP =
'Net::HTTP'
- HOST =
'host'
- COLON =
':'
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #headers ⇒ Object
- #host ⇒ Object
- #host_from_header ⇒ Object
-
#initialize(connection, request) ⇒ NetHTTPRequest
constructor
A new instance of NetHTTPRequest.
- #method ⇒ Object
- #type ⇒ Object
- #uri ⇒ Object
Constructor Details
#initialize(connection, request) ⇒ NetHTTPRequest
Returns a new instance of NetHTTPRequest.
22 23 24 25 |
# File 'lib/new_relic/agent/http_clients/net_http_wrappers.rb', line 22 def initialize(connection, request) @connection = connection @request = request end |
Instance Method Details
#[](key) ⇒ Object
50 51 52 |
# File 'lib/new_relic/agent/http_clients/net_http_wrappers.rb', line 50 def [](key) @request[key] end |
#[]=(key, value) ⇒ Object
54 55 56 |
# File 'lib/new_relic/agent/http_clients/net_http_wrappers.rb', line 54 def []=(key, value) @request[key] = value end |
#headers ⇒ Object
75 76 77 |
# File 'lib/new_relic/agent/http_clients/net_http_wrappers.rb', line 75 def headers @request.instance_variable_get(:@header) end |
#host ⇒ Object
42 43 44 |
# File 'lib/new_relic/agent/http_clients/net_http_wrappers.rb', line 42 def host host_from_header || @connection.address end |
#host_from_header ⇒ Object
36 37 38 39 40 |
# File 'lib/new_relic/agent/http_clients/net_http_wrappers.rb', line 36 def host_from_header if hostname = self[HOST] hostname.split(COLON).first end end |
#method ⇒ Object
46 47 48 |
# File 'lib/new_relic/agent/http_clients/net_http_wrappers.rb', line 46 def method @request.method end |
#type ⇒ Object
29 30 31 |
# File 'lib/new_relic/agent/http_clients/net_http_wrappers.rb', line 29 def type NET_HTTP end |
#uri ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/new_relic/agent/http_clients/net_http_wrappers.rb', line 58 def uri case @request.path when /^https?:\/\// ::NewRelic::Agent::HTTPClients::URIUtil.parse_and_normalize_url(@request.path) else connection_address = @connection.address if Resolv::IPv6::Regex.match?(connection_address) connection_address = "[#{connection_address}]" end scheme = @connection.use_ssl? ? 'https' : 'http' ::NewRelic::Agent::HTTPClients::URIUtil.parse_and_normalize_url( "#{scheme}://#{connection_address}:#{@connection.port}#{@request.path}" ) end end |