Method: HTTPAdapter#transmit

Defined in:
lib/httpadapter.rb

#transmit(request_ary, connection = nil) ⇒ Array

Transmits a request.

Parameters:

  • request_ary (Array)

    The request tuple that will be sent.

  • connection (HTTPAdapter::Connection) (defaults to: nil)

    An object representing a connection. This object represents an open HTTP connection that is used to make multiple HTTP requests.

Returns:

  • (Array)

    The response given by the server.

  • (Array)

    A tuple representing the response from the server.



145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/httpadapter.rb', line 145

def transmit(request_ary, connection=nil)
  request_ary = HTTPAdapter.verified_request(request_ary)
  if connection && !connection.kind_of?(HTTPAdapter::Connection)
    raise TypeError,
      "Expected HTTPAdapter::Connection, got #{connection.class}."
  end
  if self.respond_to?(:fetch_resource)
    response_ary = self.fetch_resource(request_ary, connection)
    return HTTPAdapter.verified_response(response_ary)
  else
    raise TypeError, 'Expected adapter to implement .fetch_resource.'
  end
end