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'

Constants inherited from AbstractRequest

AbstractRequest::COLON, AbstractRequest::LHOST, AbstractRequest::UHOST

Instance Method Summary collapse

Constructor Details

#initialize(wrapped_request) ⇒ HTTPRequest

Returns a new instance of HTTPRequest.



24
25
26
# File 'lib/new_relic/agent/http_clients/http_rb_wrappers.rb', line 24

def initialize(wrapped_request)
  @wrapped_request = wrapped_request
end

Instance Method Details

#[](key) ⇒ Object



50
51
52
# File 'lib/new_relic/agent/http_clients/http_rb_wrappers.rb', line 50

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

#[]=(key, value) ⇒ Object



54
55
56
# File 'lib/new_relic/agent/http_clients/http_rb_wrappers.rb', line 54

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

#headersObject



58
59
60
# File 'lib/new_relic/agent/http_clients/http_rb_wrappers.rb', line 58

def headers
  @wrapped_request.headers.to_hash
end

#hostObject



42
43
44
# File 'lib/new_relic/agent/http_clients/http_rb_wrappers.rb', line 42

def host
  host_from_header || @wrapped_request.host
end

#host_from_headerObject



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

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

#methodObject



46
47
48
# File 'lib/new_relic/agent/http_clients/http_rb_wrappers.rb', line 46

def method
  @wrapped_request.verb.upcase
end

#typeObject



32
33
34
# File 'lib/new_relic/agent/http_clients/http_rb_wrappers.rb', line 32

def type
  HTTP_RB
end

#uriObject



28
29
30
# File 'lib/new_relic/agent/http_clients/http_rb_wrappers.rb', line 28

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