From 6b8a38f07e87bb0cc903f71d6619259055dd0f5f Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Sun, 12 May 2013 20:26:44 -0400 Subject: [PATCH] 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. --- tornado/web.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 -- 2.47.2