From: Ben Darnell Date: Mon, 13 May 2013 00:26:44 +0000 (-0400) Subject: Respect HTTPServer's no_keep_alive option in RequestHandler.clear. X-Git-Tag: v3.1.0~76^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b8a38f07e87bb0cc903f71d6619259055dd0f5f;p=thirdparty%2Ftornado.git Respect HTTPServer's no_keep_alive option in RequestHandler.clear. Also make the keep-alive header check case-insensitive for consistency with the corresponding code in HTTPServer. Fixes #31. --- diff --git a/tornado/web.py b/tornado/web.py index bc97766eb..905621c21 100644 --- a/tornado/web.py +++ b/tornado/web.py @@ -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