changeset 2582:276de216d2c5

Respect "Connection: close" headers sent by HTTP clients. A HTTP client can indicate that it doesn't support (or doesn't want) persistent connections by sending this header. This not only makes the server more compliant with the RFC, but also reduces the run time of test-http-proxy when run with python 2.3 from ~125s to ~5s (it doesn't affect it with python 2.4, which was already ~5s).
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Fri, 07 Jul 2006 14:33:51 -0300
parents 54b152379589
children 1f4703115e28
files mercurial/hgweb/server.py
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/server.py	Sun Jul 09 11:10:11 2006 +0200
+++ b/mercurial/hgweb/server.py	Fri Jul 07 14:33:51 2006 -0300
@@ -127,6 +127,11 @@
             if h[0].lower() == 'content-length':
                 should_close = False
                 self.length = int(h[1])
+        # The value of the Connection header is a list of case-insensitive
+        # tokens separated by commas and optional whitespace.
+        if 'close' in [token.strip().lower() for token in 
+                       self.headers.get('connection', '').split(',')]:
+            should_close = True
         if should_close:
             self.send_header('Connection', 'close')
         self.close_connection = should_close