]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Respect HTTPServer's no_keep_alive option in RequestHandler.clear.
authorBen Darnell <ben@bendarnell.com>
Mon, 13 May 2013 00:26:44 +0000 (20:26 -0400)
committerBen Darnell <ben@bendarnell.com>
Mon, 13 May 2013 00:27:45 +0000 (20:27 -0400)
Also make the keep-alive header check case-insensitive for consistency
with the corresponding code in HTTPServer.

Fixes #31.

tornado/web.py

index bc97766eb96efb26b3ee2796f734cf5caea41edc..905621c21bf09cc80ae2a0b8d8f1f84c68b98548 100644 (file)
@@ -241,8 +241,11 @@ class RequestHandler(object):
             "Date": httputil.format_timestamp(time.gmtime()),
         })
         self.set_default_headers()
-        if not self.request.supports_http_1_1():
-            if self.request.headers.get("Connection") == "Keep-Alive":
+        if (not self.request.supports_http_1_1() and
+            getattr(self.request, 'connection', None) and
+            not self.request.connection.no_keep_alive):
+            conn_header = self.request.headers.get("Connection")
+            if conn_header and (conn_header.lower() == "keep-alive"):
                 self.set_header("Connection", "Keep-Alive")
         self._write_buffer = []
         self._status_code = 200