Home
Ratchet Library :: API Reference
API  ·  Manual

Module ratchet.http.server

This library provides server-side capabilities for an HTTP service. Currently the server 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

__call (self) An alias to the handle() method, allowing the http.server object to be callable as if it were a function.
handle (self) Receives an HTTP query, calls the corresponding handler, and returns the results.
new (socket, handlers, from) Creates a new HTTP server object.


Functions

__call (self)
An alias to the handle() method, allowing the http.server object to be callable as if it were a function.

Parameters

  • self: the http.server object.
handle (self)
Receives an HTTP query, calls the corresponding handler, and returns the results.

Parameters

  • self: The http.server object.
new (socket, handlers, from)
Creates a new HTTP server object. A new object should be created with this function for each socket created by accept()'ing a new connection on a listening socket.

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.
  • handlers: Table whose keys correspond to supported HTTP commands. The command is called as a method of this table, e.g. handlers:GET(...), with the arguments being the URI, headers, data, and source address.
  • from: Passed as the last argument to a handler function, typically used to send the source address of the connection (the second value returned by accept()).

Return value:

a new http.server object.