Class: HTTPI::Adapter::Typhoeus
- Inherits:
-
Base
- Object
- Base
- HTTPI::Adapter::Typhoeus
- Defined in:
- lib/httpi/adapter/typhoeus.rb
Defined Under Namespace
Classes: TyphoesConnectionError
Instance Method Summary collapse
-
#initialize(request) ⇒ Typhoeus
constructor
A new instance of Typhoeus.
- #request(http_method) ⇒ Object
Constructor Details
#initialize(request) ⇒ Typhoeus
Returns a new instance of Typhoeus.
12 13 14 |
# File 'lib/httpi/adapter/typhoeus.rb', line 12 def initialize(request) @request = request end |
Instance Method Details
#request(http_method) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/httpi/adapter/typhoeus.rb', line 16 def request(http_method) @client = ::Typhoeus::Request.new( @request.url, method: http_method, body: @request.body, headers: @request.headers ) configure_auth configure_proxy configure_ssl configure_timeouts response = @client.run if response.timed_out? raise TimeoutError elsif response.response_code == 0 case response. when /ssl/i raise SSLError, response. else raise TyphoesConnectionError, response. end else Response.new(response.code, response.headers, response.body) end end |