Class: OneApm::Support::HTTPClients::NetHTTPRequest
- Inherits:
-
Object
- Object
- OneApm::Support::HTTPClients::NetHTTPRequest
- Defined in:
- lib/one_apm/support/http_clients/net_http_wrappers.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #body ⇒ Object
- #host ⇒ Object
-
#initialize(connection, request) ⇒ NetHTTPRequest
constructor
A new instance of NetHTTPRequest.
- #method ⇒ Object
- #params ⇒ Object
- #port ⇒ Object
- #post_params ⇒ Object
- #query ⇒ Object
- #type ⇒ Object
- #uri ⇒ Object
Constructor Details
#initialize(connection, request) ⇒ NetHTTPRequest
Returns a new instance of NetHTTPRequest.
7 8 9 10 |
# File 'lib/one_apm/support/http_clients/net_http_wrappers.rb', line 7 def initialize(connection, request) @connection = connection @request = request end |
Instance Method Details
#[](key) ⇒ Object
32 33 34 |
# File 'lib/one_apm/support/http_clients/net_http_wrappers.rb', line 32 def [](key) @request[key] end |
#[]=(key, value) ⇒ Object
36 37 38 |
# File 'lib/one_apm/support/http_clients/net_http_wrappers.rb', line 36 def []=(key, value) @request[key] = value end |
#body ⇒ Object
54 55 56 |
# File 'lib/one_apm/support/http_clients/net_http_wrappers.rb', line 54 def body @request.body end |
#host ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/one_apm/support/http_clients/net_http_wrappers.rb', line 16 def host if hostname = self['host'] hostname.split(':').first else @connection.address end end |
#method ⇒ Object
28 29 30 |
# File 'lib/one_apm/support/http_clients/net_http_wrappers.rb', line 28 def method @request.method end |
#params ⇒ Object
62 63 64 |
# File 'lib/one_apm/support/http_clients/net_http_wrappers.rb', line 62 def params post_params.merge(query) end |
#port ⇒ Object
24 25 26 |
# File 'lib/one_apm/support/http_clients/net_http_wrappers.rb', line 24 def port @connection.port end |
#post_params ⇒ Object
58 59 60 |
# File 'lib/one_apm/support/http_clients/net_http_wrappers.rb', line 58 def post_params body.nil?? {} : CGI.parse(body) end |
#query ⇒ Object
50 51 52 |
# File 'lib/one_apm/support/http_clients/net_http_wrappers.rb', line 50 def query uri.query.nil?? {} : CGI.parse(uri.query) end |
#type ⇒ Object
12 13 14 |
# File 'lib/one_apm/support/http_clients/net_http_wrappers.rb', line 12 def type 'Net::HTTP' end |
#uri ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/one_apm/support/http_clients/net_http_wrappers.rb', line 40 def uri case @request.path when /^https?:\/\// URI(@request.path) else scheme = @connection.use_ssl? ? 'https' : 'http' URI("#{scheme}://#{@connection.address}:#{@connection.port}#{@request.path}") end end |