Home
Ratchet Library :: API Reference
API  ·  Manual

Module ratchet.http.client

This library provides client-side access to an HTTP service, commonly used in many different cases across the Web. Currently the client only supports HTTP/1.0, with no current plans to support 1.1 or higher, as it is only provided for convenience and as an example of using the ratchet libraries.

Functions

new (socket) Creates a new HTTP client object.
query (self, command, uri, headers, data) Sends an HTTP query, and returns the results.


Functions

new (socket)
Creates a new HTTP client object.

Parameters

  • socket: Used as the underlying socket for the query, under the assumption that encryption has been established as needed and no other I/O has taken place.

Return value:

a new http.client object.
query (self, command, uri, headers, data)
Sends an HTTP query, and returns the results.

Parameters

  • self: the http.client object.
  • command: The HTTP command to use, such as "PUT" or "GET".
  • uri: The URI to query.
  • headers: A table whose keys are header names and values are arrays of strings. Each string in the value array will result in a new header of the given name.
  • data: Additional data to send in the body of the query. It is usually important to specify a "Content-Length" header with the length of this string.

Return value:

In order: the return code of the query, the descriptive return message, additional headers returned (in the same format as the headers parameter), and a string of data returned by the query (if any).