Class: D13n::Metric::HTTPClients::NetHTTPClientRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/d13n/metric/http_clients/net_http_wrappers.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection, request) ⇒ NetHTTPClientRequest

Returns a new instance of NetHTTPClientRequest.



4
5
6
7
# File 'lib/d13n/metric/http_clients/net_http_wrappers.rb', line 4

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

Instance Method Details

#[](key) ⇒ Object



21
22
23
# File 'lib/d13n/metric/http_clients/net_http_wrappers.rb', line 21

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

#[]=(key, value) ⇒ Object



25
26
27
# File 'lib/d13n/metric/http_clients/net_http_wrappers.rb', line 25

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

#hostObject



13
14
15
16
17
18
19
# File 'lib/d13n/metric/http_clients/net_http_wrappers.rb', line 13

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

#typeObject



9
10
11
# File 'lib/d13n/metric/http_clients/net_http_wrappers.rb', line 9

def type
  'Net::HTTP'
end

#uriObject



29
30
31
32
33
34
35
36
37
# File 'lib/d13n/metric/http_clients/net_http_wrappers.rb', line 29

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