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

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

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ TyphoeusHTTPRequest

Returns a new instance of TyphoeusHTTPRequest.



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

def initialize(request)
  @request = request
  @uri = URI.parse(request.url)
end

Instance Method Details

#[](key) ⇒ Object



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

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

#[]=(key, value) ⇒ Object



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

def []=(key, value)
  @request.options[:headers] ||= {}
  @request.options[:headers][key] = value
end

#hostObject



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

def host
  self['host'] || self['Host'] || @uri.host
end

#methodObject



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

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

#typeObject



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

def type
  "Typhoeus"
end

#uriObject



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

def uri
  @uri
end