Class: NewRelic::Agent::HTTPClients::TyphoeusHTTPRequest

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

Constant Summary collapse

TYPHOEUS =
'Typhoeus'.freeze
GET =
'GET'.freeze

Constants inherited from AbstractRequest

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

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ TyphoeusHTTPRequest

Returns a new instance of TyphoeusHTTPRequest.



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

def initialize(request)
  @request = request
  @uri = case request.url
    when ::URI then request.url
    else NewRelic::Agent::HTTPClients::URIUtil.parse_and_normalize_url(request.url)
  end
end

Instance Method Details

#[](key) ⇒ Object



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

def [](key)
  return nil unless @request.options && headers

  headers[key]
end

#[]=(key, value) ⇒ Object



71
72
73
# File 'lib/new_relic/agent/http_clients/typhoeus_wrappers.rb', line 71

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

#headersObject



75
76
77
# File 'lib/new_relic/agent/http_clients/typhoeus_wrappers.rb', line 75

def headers
  @request.options[:headers] || {}
end

#hostObject



55
56
57
# File 'lib/new_relic/agent/http_clients/typhoeus_wrappers.rb', line 55

def host
  host_from_header || @uri.host
end

#host_from_headerObject



51
52
53
# File 'lib/new_relic/agent/http_clients/typhoeus_wrappers.rb', line 51

def host_from_header
  self[LHOST] || self[UHOST]
end

#methodObject



61
62
63
# File 'lib/new_relic/agent/http_clients/typhoeus_wrappers.rb', line 61

def method
  (@request.options[:method] || GET).to_s.upcase
end

#typeObject



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

def type
  TYPHOEUS
end

#uriObject



79
80
81
# File 'lib/new_relic/agent/http_clients/typhoeus_wrappers.rb', line 79

def uri
  @uri
end