Class: OneApm::Support::HTTPClients::TyphoeusHTTPRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/one_apm/support/http_clients/typhoeus_wrappers.rb

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ TyphoeusHTTPRequest

Returns a new instance of TyphoeusHTTPRequest.



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

def initialize(request)
  @request = request
  @uri = case request.url
    when ::URI then request.url
    else OneApm::Support::HTTPClients::URIUtil.parse_url(request.url)
    end
end

Instance Method Details

#[](key) ⇒ Object



57
58
59
60
# File 'lib/one_apm/support/http_clients/typhoeus_wrappers.rb', line 57

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

#[]=(key, value) ⇒ Object



62
63
64
65
# File 'lib/one_apm/support/http_clients/typhoeus_wrappers.rb', line 62

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

#hostObject



49
50
51
# File 'lib/one_apm/support/http_clients/typhoeus_wrappers.rb', line 49

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

#methodObject



53
54
55
# File 'lib/one_apm/support/http_clients/typhoeus_wrappers.rb', line 53

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

#typeObject



45
46
47
# File 'lib/one_apm/support/http_clients/typhoeus_wrappers.rb', line 45

def type
  "Typhoeus"
end

#uriObject



67
68
69
# File 'lib/one_apm/support/http_clients/typhoeus_wrappers.rb', line 67

def uri
  @uri
end