Class: HTTPI::Adapter::Excon

Inherits:
Base
  • Object
show all
Defined in:
lib/httpi/adapter/excon.rb

Overview

HTTPI::Adapter::Excon

Adapter for the Excon client. github.com/geemus/excon

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

register

Constructor Details

#initialize(request) ⇒ Excon

Returns a new instance of Excon.



15
16
17
18
# File 'lib/httpi/adapter/excon.rb', line 15

def initialize(request)
  @request = request
  @client  = ::Excon::Connection.new client_opts
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



20
21
22
# File 'lib/httpi/adapter/excon.rb', line 20

def client
  @client
end

Instance Method Details

#request(method) ⇒ Object

Executes arbitrary HTTP requests.

See Also:



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/httpi/adapter/excon.rb', line 24

def request(method)
  respond_with @client.send(method)
rescue ::Excon::Errors::SocketError => e
  case e.message
  when /verify certificate/
    raise SSLError
  else
    $!.extend ConnectionError
  end
  raise
end