class OneApm::Support::HTTPClients::NetHTTPRequest

Public Class Methods

new(connection, request) click to toggle source
# File lib/one_apm/support/http_clients/net_http_wrappers.rb, line 7
def initialize(connection, request)
  @connection = connection
  @request = request
end

Public Instance Methods

[](key) click to toggle source
# File lib/one_apm/support/http_clients/net_http_wrappers.rb, line 32
def [](key)
  @request[key]
end
[]=(key, value) click to toggle source
# File lib/one_apm/support/http_clients/net_http_wrappers.rb, line 36
def []=(key, value)
  @request[key] = value
end
body() click to toggle source
# File lib/one_apm/support/http_clients/net_http_wrappers.rb, line 54
def body
  @request.body
end
host() click to toggle source
# 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
method() click to toggle source
# File lib/one_apm/support/http_clients/net_http_wrappers.rb, line 28
def method
  @request.method
end
params() click to toggle source
# File lib/one_apm/support/http_clients/net_http_wrappers.rb, line 62
def params
  post_params.merge(query)
end
port() click to toggle source
# File lib/one_apm/support/http_clients/net_http_wrappers.rb, line 24
def port
  @connection.port
end
post_params() click to toggle source
# File lib/one_apm/support/http_clients/net_http_wrappers.rb, line 58
def post_params
  body.nil?? {} :  CGI.parse(body)
end
query() click to toggle source
# File lib/one_apm/support/http_clients/net_http_wrappers.rb, line 50
def query
  uri.query.nil?? {} : CGI.parse(uri.query)
end
type() click to toggle source
# File lib/one_apm/support/http_clients/net_http_wrappers.rb, line 12
def type
  'Net::HTTP'
end
uri() click to toggle source
# File lib/one_apm/support/http_clients/net_http_wrappers.rb, line 40
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