Class: NewRelic::Agent::HTTPClients::ExconHTTPRequest

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

Constant Summary collapse

EXCON =
'Excon'
LHOST =
'host'
UHOST =
'Host'
COLON =
':'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(datum) ⇒ ExconHTTPRequest

Returns a new instance of ExconHTTPRequest.



54
55
56
57
58
59
60
61
# File 'lib/new_relic/agent/http_clients/excon_wrappers.rb', line 54

def initialize(datum)
  @datum = datum

  @method = @datum[:method].to_s.upcase
  @scheme = @datum[:scheme]
  @port = @datum[:port]
  @path = @datum[:path]
end

Instance Attribute Details

#methodObject (readonly)

Returns the value of attribute method.



47
48
49
# File 'lib/new_relic/agent/http_clients/excon_wrappers.rb', line 47

def method
  @method
end

Instance Method Details

#[](key) ⇒ Object



77
78
79
# File 'lib/new_relic/agent/http_clients/excon_wrappers.rb', line 77

def [](key)
  headers[key]
end

#[]=(key, value) ⇒ Object



81
82
83
# File 'lib/new_relic/agent/http_clients/excon_wrappers.rb', line 81

def []=(key, value)
  headers[key] = value
end

#headersObject



90
91
92
# File 'lib/new_relic/agent/http_clients/excon_wrappers.rb', line 90

def headers
  @datum[:headers]
end

#hostObject



73
74
75
# File 'lib/new_relic/agent/http_clients/excon_wrappers.rb', line 73

def host
  host_from_header || @datum[:host]
end

#host_from_headerObject



67
68
69
70
71
# File 'lib/new_relic/agent/http_clients/excon_wrappers.rb', line 67

def host_from_header
  if hostname = (headers[LHOST] || headers[UHOST])
    hostname.split(COLON).first
  end
end

#typeObject



63
64
65
# File 'lib/new_relic/agent/http_clients/excon_wrappers.rb', line 63

def type
  EXCON
end

#uriObject



85
86
87
88
# File 'lib/new_relic/agent/http_clients/excon_wrappers.rb', line 85

def uri
  url = "#{@scheme}://#{host}:#{@port}#{@path}"
  URIUtil.parse_and_normalize_url(url)
end