web_protocol

Module Contents

Classes

RequestPayloadError() Payload parsing error.
PayloadAccessError() Payload was accesed after responce was sent.
RequestHandler(self,manager) HTTP protocol implementation.
class RequestPayloadError

Payload parsing error.

class PayloadAccessError

Payload was accesed after responce was sent.

class RequestHandler(manager)

HTTP protocol implementation.

RequestHandler handles incoming HTTP request. It reads request line, request headers and request payload and calls handle_request() method. By default it always returns with 404 response.

RequestHandler handles errors in incoming request, like bad status line, bad headers or incomplete payload. If any error occurs, connection gets closed.

Parameters:
  • keepalive_timeout (int or None) – number of seconds before closing keep-alive connection
  • tcp_keepalive (bool) – TCP keep-alive is on, default is on
  • debug (bool) – enable debug mode
  • logger (aiohttp.log.server_logger) – custom logger object
  • access_log_class (aiohttp.abc.AbstractAccessLogger) – custom class for access_logger
  • access_log (aiohttp.log.server_logger) – custom logging object
  • access_log_format (str) – access log format string
  • loop – Optional event loop
  • max_line_size (int) – Optional maximum header line size
  • max_field_size (int) – Optional maximum header field size
  • max_headers (int) – Optional maximum header size
__init__(manager)
__repr__()
keepalive_timeout()
shutdown(timeout=15.0)

Worker process is about to exit, we need cleanup everything and stop accepting requests. It is especially important for keep-alive connections.

connection_made(transport)
connection_lost(exc)
set_parser(parser)
eof_received()
data_received(data)
keep_alive(val)

Set keep-alive connection mode.

Parameters:val (bool) – new state.
close()

Stop accepting new pipelinig messages and close connection when handlers done processing messages

force_close()

Force close connection

log_access(request, response, time)
log_debug(*args, **kw)
log_exception(*args, **kw)
_process_keepalive()
pause_reading()
resume_reading()
start()

Process incoming request.

It reads request line, request headers and request payload, then calls handle_request() method. Subclass has to override handle_request(). start() handles various exceptions in request or response handling. Connection is being closed always unless keep_alive(True) specified.

handle_error(request, status=500, exc=None, message=None)

Handle errors.

Returns HTTP response with specific status code. Logs additional information. It always closes current connection.

handle_parse_error(writer, status, exc=None, message=None)