Class: HTTPI::Adapter::HTTPClient
- Defined in:
- lib/httpi/adapter/httpclient.rb
Overview
HTTPI::Adapter::HTTPClient
Adapter for the HTTPClient client. rubygems.org/gems/httpclient
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#initialize(request) ⇒ HTTPClient
constructor
A new instance of HTTPClient.
-
#request(method) ⇒ Object
Executes arbitrary HTTP requests.
Methods inherited from Base
Constructor Details
#initialize(request) ⇒ HTTPClient
Returns a new instance of HTTPClient.
15 16 17 18 |
# File 'lib/httpi/adapter/httpclient.rb', line 15 def initialize(request) @request = request @client = ::HTTPClient.new end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
20 21 22 |
# File 'lib/httpi/adapter/httpclient.rb', line 20 def client @client end |
Instance Method Details
#request(method) ⇒ Object
Executes arbitrary HTTP requests.
24 25 26 27 28 29 30 31 32 |
# File 'lib/httpi/adapter/httpclient.rb', line 24 def request(method) setup_client respond_with @client.request(method, @request.url, nil, @request.body, @request.headers, &@request.on_body) rescue OpenSSL::SSL::SSLError raise SSLError rescue Errno::ECONNREFUSED # connection refused $!.extend ConnectionError raise end |