Class: OneApm::Support::HTTPClients::TyphoeusHTTPRequest
- Inherits:
-
Object
- Object
- OneApm::Support::HTTPClients::TyphoeusHTTPRequest
- Defined in:
- lib/one_apm/support/http_clients/typhoeus_wrappers.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #body ⇒ Object
- #host ⇒ Object
-
#initialize(request) ⇒ TyphoeusHTTPRequest
constructor
A new instance of TyphoeusHTTPRequest.
- #method ⇒ Object
- #params ⇒ Object
- #port ⇒ Object
- #post_params ⇒ Object
- #query ⇒ Object
- #type ⇒ Object
- #uri ⇒ Object
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. && @request.[:headers] @request.[: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.[:headers] ||= {} @request.[:headers][key] = value end |
#body ⇒ Object
79 80 81 |
# File 'lib/one_apm/support/http_clients/typhoeus_wrappers.rb', line 79 def body @request.[:body] end |
#host ⇒ Object
49 50 51 |
# File 'lib/one_apm/support/http_clients/typhoeus_wrappers.rb', line 49 def host @uri.host end |
#method ⇒ Object
57 58 59 |
# File 'lib/one_apm/support/http_clients/typhoeus_wrappers.rb', line 57 def method (@request.[:method] || 'GET').to_s.upcase end |
#params ⇒ Object
87 88 89 |
# File 'lib/one_apm/support/http_clients/typhoeus_wrappers.rb', line 87 def params post_params.merge(query) end |
#port ⇒ Object
53 54 55 |
# File 'lib/one_apm/support/http_clients/typhoeus_wrappers.rb', line 53 def port @uri.port end |
#post_params ⇒ Object
83 84 85 |
# File 'lib/one_apm/support/http_clients/typhoeus_wrappers.rb', line 83 def post_params body.nil?? {} : CGI.parse(body) end |
#query ⇒ Object
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 |
#type ⇒ Object
45 46 47 |
# File 'lib/one_apm/support/http_clients/typhoeus_wrappers.rb', line 45 def type "Typhoeus" end |
#uri ⇒ Object
71 72 73 |
# File 'lib/one_apm/support/http_clients/typhoeus_wrappers.rb', line 71 def uri @uri end |