Module: Conduit::Core::Connection::InstanceMethods

Extended by:
Forwardable
Defined in:
lib/conduit/core/connection.rb

Instance Method Summary collapse

Instance Method Details

#request(params, &block) ⇒ Object

Make a request

Parameters:

  • params (Hash)

Options Hash (params):

  • :body (String)

    text to be sent over a socket

  • :headers (Hash<Symbol, String>)

    The default headers to supply in a request

  • :host (String)

    The destination host’s reachable DNS name or IP, in the form of a String

  • :path (String)

    appears after ‘scheme://host:port/’

  • :port (Fixnum)

    The port on which to connect, to the destination host

  • :query (Hash)

    appended to the ‘scheme://host:port/path/’ in the form of ‘?key=value’

  • :scheme (String)

    The protocol; ‘https’ causes OpenSSL to be used

  • :response_block (Proc)


49
50
51
52
53
54
55
56
57
# File 'lib/conduit/core/connection.rb', line 49

def request(params, &block)
  params[:headers] ||= {}
  params[:headers]['User-Agent'] ||= "conduit/#{Conduit::VERSION}"
  connection.request(params, &block)
rescue Excon::Errors::Timeout => timeout
  raise(Conduit::Timeout, timeout.message)
rescue Excon::Errors::Error => error
  raise(Conduit::ConnectionError, error.message)
end