Class: CF::HTTP::NetHTTPAdapter
- Inherits:
-
Object
- Object
- CF::HTTP::NetHTTPAdapter
- Defined in:
- lib/cf/http/net_http_adapter.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ NetHTTPAdapter
constructor
A new instance of NetHTTPAdapter.
- #request(method, url, body = nil, headers = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ NetHTTPAdapter
Returns a new instance of NetHTTPAdapter.
10 11 12 13 14 15 16 17 |
# File 'lib/cf/http/net_http_adapter.rb', line 10 def initialize( = {}) = { timeout: 30, open_timeout: 10, use_ssl: true, verify_mode: OpenSSL::SSL::VERIFY_PEER }.merge() end |
Instance Method Details
#request(method, url, body = nil, headers = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/cf/http/net_http_adapter.rb', line 19 def request(method, url, body = nil, headers = {}) uri = URI(url) Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") do |http| configure_http(http) request = build_request(method, uri, body, headers) response = http.request(request) handle_response(response) end end |