From: Ben Darnell Date: Sat, 1 Dec 2012 23:17:07 +0000 (-0500) Subject: Document the need to pass Connection: close when using no_keep_alive. X-Git-Tag: v3.0.0~208 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e25b753eba26e07a054da2610965e02c8a11c852;p=thirdparty%2Ftornado.git Document the need to pass Connection: close when using no_keep_alive. Closes #641. --- diff --git a/tornado/httpserver.py b/tornado/httpserver.py index 2ef784183..af441d930 100644 --- a/tornado/httpserver.py +++ b/tornado/httpserver.py @@ -67,16 +67,21 @@ class HTTPServer(TCPServer): http_server.listen(8888) ioloop.IOLoop.instance().start() - `HTTPServer` is a very basic connection handler. Beyond parsing the - HTTP request body and headers, the only HTTP semantics implemented - in `HTTPServer` is HTTP/1.1 keep-alive connections. We do not, however, - implement chunked encoding, so the request callback must provide a - ``Content-Length`` header or implement chunked encoding for HTTP/1.1 - requests for the server to run correctly for HTTP/1.1 clients. If - the request handler is unable to do this, you can provide the - ``no_keep_alive`` argument to the `HTTPServer` constructor, which will - ensure the connection is closed on every request no matter what HTTP - version the client is using. + `HTTPServer` is a very basic connection handler. It parses the request + headers and body, but the request callback is responsible for producing + the response exactly as it will appear on the wire. This affords + maximum flexibility for applications to implement whatever parts + of HTTP responses are required. + + `HTTPServer` supports keep-alive connections by default + (automatically for HTTP/1.1, or for HTTP/1.0 when the client + requests ``Connection: keep-alive``). This means that the request + callback must generate a properly-framed response, using either + the ``Content-Length`` header or ``Transfer-Encoding: chunked``. + Applications that are unable to frame their responses properly + should instead return a ``Connection: close`` header in each + response and pass ``no_keep_alive=True`` to the `HTTPServer` + constructor. If ``xheaders`` is ``True``, we support the ``X-Real-Ip``/``X-Forwarded-For`` and