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



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

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

#[]=(key, value) ⇒ Object



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

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

#bodyObject



79
80
81
# File 'lib/one_apm/support/http_clients/typhoeus_wrappers.rb', line 79

def body
  @request.options[:body]
end

#hostObject



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

def host
  @uri.host
end

#methodObject



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

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

#paramsObject



87
88
89
# File 'lib/one_apm/support/http_clients/typhoeus_wrappers.rb', line 87

def params
  post_params.merge(query)
end

#portObject



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

def port
  @uri.port
end

#post_paramsObject



83
84
85
# File 'lib/one_apm/support/http_clients/typhoeus_wrappers.rb', line 83

def post_params
  body.nil?? {} :  CGI.parse(body)
end

#queryObject



75
76
77
# File 'lib/one_apm/support/http_clients/typhoeus_wrappers.rb', line 75

def query
  @uri.query.nil?? {} : CGI.parse(@uri.query)
end

#typeObject



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

def type
  "Typhoeus"
end

#uriObject



71
72
73
# File 'lib/one_apm/support/http_clients/typhoeus_wrappers.rb', line 71

def uri
  @uri
end