Pluggdapps

Component system. Web framework. And more ...

server – HTTP web server based on EPoll.

HTTP web server based on epoll event-loop using non-blocking sockets. In addition to I/O events, the server also does generic callback handling and schedule time-based events.

Module contents

class pluggdapps.web.server.HTTPEPollServer(pa, *args, **kwargs)[source]

Bases: pluggdapps.plugin.Plugin

A non-blocking, single-threaded HTTP Server plugin. HTTPEPollServer can serve SSL traffic with Python 2.6+ and OpenSSL. To make this server serve SSL traffic, configure this plugin with ssl.* settings which is required for the ssl.wrap_socket method, including “certfile” and “keyfile”.

Server resolves application for HTTP requests and dispatches them to corresponding IWebApp plugin. Finishing the request does not necessarily close the connection in the case of HTTP/1.1 keep-alive requests.

ioloop = None

IOLoop instance for event-polling.

start()[source]

pluggdapps.interfaces.IHTTPServer.start() interface method.

stop()[source]

Stop listening for new connections. Expected to be called in case of exceptions and SIGNALS. Refer pluggdapps.interfaces.IHTTPServer.start() interface method.

close_connection(httpconn)[source]

pluggdapps.interfaces.IHTTPServer.close_connection() interface method.

class pluggdapps.web.server.HTTPConnection(pa, *args, **kwargs)[source]

Bases: pluggdapps.plugin.Plugin

IHTTPConnection plugin to handle http connections. Every client connection corresponds to an instance of this plugin, handle request, parse headers and bodies, and execute the request callback and writes the response back.

Accepts only HTTP/1.1 request. If otherwise, reponds with bad-request (400) and closes the connection.

write_callback = None

Call-back for writing data to connection.

close_callback = None

Call-back when connection is closed.

finish_callback = None

Call-back when request is finished.

reqdata = None

Tuple of new request’s start line and headers, (method, uri, version, hdrs)

chunk = None

Tuple of on-going request chunk, (chunk_size, chunk_ext, chunk_data)

stream = None

IOStream object.

iotimeout = None

Connection timeout from ioloop.

get_ssl_certificate()[source]

pluggdapps.interfaces.IHTTPConnection.get_ssl_certificate() interface method.

set_close_callback(callback)[source]

pluggdapps.interfaces.IHTTPConnection.set_close_callback() interface method.

set_finish_callback(callback)[source]

pluggdapps.interfaces.IHTTPConnection.set_finish_callback() interface method.

handle_request(method, uri, version, headers, body=None, chunk=None, trailers=None)[source]

pluggdapps.interfaces.IHTTPConnection.handle_request() interface method.

handle_chunk(chunk, trailers=None)[source]

pluggdapps.interfaces.IHTTPConnection.handle_chunk() interface method.

close()[source]

pluggdapps.interfaces.IHTTPConnection.close() interface method.

pluggdapps.web.server.add_accept_handler(server, sock, callback, ioloop)[source]

Adds an IOLoop event handler to accept new connections on sock. When a connection is accepted, callback(connection, address) will be run (connection is a socket object, and address is the address of the other end of the connection). Note that this signature is different from the callback(fd, events) signature used for IOLoop handlers.