tornado.http1connection – HTTP/1.x client/server implementation¶
Client and server implementations of HTTP/1.x.
New in version 4.0.
- class tornado.http1connection.HTTP1ConnectionParameters(no_keep_alive: bool = False, chunk_size: Optional[int] = None, max_header_size: Optional[int] = None, header_timeout: Optional[float] = None, max_body_size: Optional[int] = None, body_timeout: Optional[float] = None, decompress: bool = False)¶
no_keep_alive (bool) – If true, always close the connection after one request.
chunk_size (int) – how much data to read into memory at once
max_header_size (int) – maximum amount of data for HTTP headers
header_timeout (float) – how long to wait for all headers (seconds)
max_body_size (int) – maximum amount of data for body
body_timeout (float) – how long to wait while reading body (seconds)
decompress (bool) – if true, decode incoming
- class tornado.http1connection.HTTP1Connection(stream: IOStream, is_client: bool, params: Optional[HTTP1ConnectionParameters] = None, context: Optional[object] = None)¶
Implements the HTTP/1.x protocol.
This class can be on its own for clients, or via
- read_response(delegate: HTTPMessageDelegate) Awaitable[bool] ¶
Read a single HTTP response.
delegate – a
Futurethat resolves to a bool after the full response has been read. The result is true if the stream is still open.
- set_close_callback(callback: Optional[Callable[, None]]) None ¶
Sets a callback that will be run when the connection is closed.
Note that this callback is slightly different from
HTTPMessageDelegatemethod is called when the connection is closed while receiving a message. This callback is used when there is not an active delegate (for example, on the server side this callback is used if the client closes the connection after sending its request but before receiving all the response.
- detach() IOStream ¶
Take control of the underlying stream.
Returns the underlying
IOStreamobject and stops all further HTTP processing. May only be called during
HTTPMessageDelegate.headers_received. Intended for implementing protocols like websockets that tunnel over an HTTP handshake.
- set_body_timeout(timeout: float) None ¶
Sets the body timeout for a single request.
Overrides the value from
- set_max_body_size(max_body_size: int) None ¶
Sets the body size limit for a single request.
Overrides the value from
- write_headers(start_line: Union[RequestStartLine, ResponseStartLine], headers: HTTPHeaders, chunk: Optional[bytes] = None) Future[None] ¶
- write(chunk: bytes) Future[None] ¶
- class tornado.http1connection.HTTP1ServerConnection(stream: IOStream, params: Optional[HTTP1ConnectionParameters] = None, context: Optional[object] = None)¶
An HTTP/1.x server.
- coroutine close() None ¶
Closes the connection.
Futurethat resolves after the serving loop has exited.