Class: NewRelic::Agent::HTTPClients::NetHTTPRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/new_relic/agent/http_clients/net_http_wrappers.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection, request) ⇒ NetHTTPRequest

Returns a new instance of NetHTTPRequest.



9
10
11
12
# File 'lib/new_relic/agent/http_clients/net_http_wrappers.rb', line 9

def initialize(connection, request)
  @connection = connection
  @request = request
end

Instance Method Details

#[](key) ⇒ Object



26
27
28
# File 'lib/new_relic/agent/http_clients/net_http_wrappers.rb', line 26

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

#[]=(key, value) ⇒ Object



30
31
32
# File 'lib/new_relic/agent/http_clients/net_http_wrappers.rb', line 30

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

#hostObject



18
19
20
# File 'lib/new_relic/agent/http_clients/net_http_wrappers.rb', line 18

def host
  @connection.address
end

#methodObject



22
23
24
# File 'lib/new_relic/agent/http_clients/net_http_wrappers.rb', line 22

def method
  @request.method
end

#typeObject



14
15
16
# File 'lib/new_relic/agent/http_clients/net_http_wrappers.rb', line 14

def type
  'Net::HTTP'
end

#uriObject



34
35
36
37
38
39
40
41
42
# File 'lib/new_relic/agent/http_clients/net_http_wrappers.rb', line 34

def uri
  case @request.path
  when /^https?:\/\//
    URI(@request.path)
  else
    scheme = @connection.use_ssl? ? 'https' : 'http'
    URI("#{scheme}://#{@connection.address}:#{@connection.port}#{@request.path}")
  end
end