comparison mercurial/hgweb/server.py @ 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 ab460a3f0e3a
children c4325f0a9b91
comparison
equal deleted inserted replaced
2581:54b152379589 2582:276de216d2c5
125 for h in self.saved_headers: 125 for h in self.saved_headers:
126 self.send_header(*h) 126 self.send_header(*h)
127 if h[0].lower() == 'content-length': 127 if h[0].lower() == 'content-length':
128 should_close = False 128 should_close = False
129 self.length = int(h[1]) 129 self.length = int(h[1])
130 # The value of the Connection header is a list of case-insensitive
131 # tokens separated by commas and optional whitespace.
132 if 'close' in [token.strip().lower() for token in
133 self.headers.get('connection', '').split(',')]:
134 should_close = True
130 if should_close: 135 if should_close:
131 self.send_header('Connection', 'close') 136 self.send_header('Connection', 'close')
132 self.close_connection = should_close 137 self.close_connection = should_close
133 self.end_headers() 138 self.end_headers()
134 self.sent_headers = True 139 self.sent_headers = True