Class: NewRelic::Agent::HTTPClients::HTTPRequest

Inherits:
AbstractRequest show all
Defined in:
lib/new_relic/agent/http_clients/http_rb_wrappers.rb

Constant Summary collapse

HTTP_RB =
'http.rb'
HOST =
'host'
COLON =
':'

Instance Method Summary collapse

Constructor Details

#initialize(wrapped_request) ⇒ HTTPRequest

Returns a new instance of HTTPRequest.



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

def initialize(wrapped_request)
  @wrapped_request = wrapped_request
end

Instance Method Details

#[](key) ⇒ Object



52
53
54
# File 'lib/new_relic/agent/http_clients/http_rb_wrappers.rb', line 52

def [](key)
  @wrapped_request.headers[key]
end

#[]=(key, value) ⇒ Object



56
57
58
# File 'lib/new_relic/agent/http_clients/http_rb_wrappers.rb', line 56

def []=(key, value)
  @wrapped_request.headers[key] = value
end

#headersObject



60
61
62
# File 'lib/new_relic/agent/http_clients/http_rb_wrappers.rb', line 60

def headers
  @wrapped_request.headers.to_hash
end

#hostObject



44
45
46
# File 'lib/new_relic/agent/http_clients/http_rb_wrappers.rb', line 44

def host
  host_from_header || @wrapped_request.host
end

#host_from_headerObject



38
39
40
41
42
# File 'lib/new_relic/agent/http_clients/http_rb_wrappers.rb', line 38

def host_from_header
  if hostname = self[HOST]
    hostname.split(COLON).first
  end
end

#methodObject



48
49
50
# File 'lib/new_relic/agent/http_clients/http_rb_wrappers.rb', line 48

def method
  @wrapped_request.verb.upcase
end

#typeObject



34
35
36
# File 'lib/new_relic/agent/http_clients/http_rb_wrappers.rb', line 34

def type
  HTTP_RB
end

#uriObject



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

def uri
  @uri ||= URIUtil.parse_and_normalize_url(@wrapped_request.uri)
end