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'

Constants inherited from AbstractRequest

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(datum) ⇒ ExconHTTPRequest

Returns a new instance of ExconHTTPRequest.



51
52
53
54
55
56
57
58
# File 'lib/new_relic/agent/http_clients/excon_wrappers.rb', line 51

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



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

def [](key)
  headers[key]
end

#[]=(key, value) ⇒ Object



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

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

#headersObject



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

def headers
  @datum[:headers]
end

#hostObject



70
71
72
# File 'lib/new_relic/agent/http_clients/excon_wrappers.rb', line 70

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

#host_from_headerObject



64
65
66
67
68
# File 'lib/new_relic/agent/http_clients/excon_wrappers.rb', line 64

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

#typeObject



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

def type
  EXCON
end

#uriObject



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

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