Class: OneApm::Support::HTTPClients::NetHTTPRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/one_apm/support/http_clients/net_http_wrappers.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection, request) ⇒ NetHTTPRequest

Returns a new instance of NetHTTPRequest.



7
8
9
10
# File 'lib/one_apm/support/http_clients/net_http_wrappers.rb', line 7

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

Instance Method Details

#[](key) ⇒ Object



28
29
30
# File 'lib/one_apm/support/http_clients/net_http_wrappers.rb', line 28

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

#[]=(key, value) ⇒ Object



32
33
34
# File 'lib/one_apm/support/http_clients/net_http_wrappers.rb', line 32

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

#hostObject



16
17
18
19
20
21
22
# File 'lib/one_apm/support/http_clients/net_http_wrappers.rb', line 16

def host
  if hostname = self['host']
    hostname.split(':').first
  else
    @connection.address
  end
end

#methodObject



24
25
26
# File 'lib/one_apm/support/http_clients/net_http_wrappers.rb', line 24

def method
  @request.method
end

#typeObject



12
13
14
# File 'lib/one_apm/support/http_clients/net_http_wrappers.rb', line 12

def type
  'Net::HTTP'
end

#uriObject



36
37
38
39
40
41
42
43
44
# File 'lib/one_apm/support/http_clients/net_http_wrappers.rb', line 36

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