diff mercurial/hgweb/server.py @ 2434:a2df85adface

http server: support persistent connections. only "hg serve" affected yet. http server running cgi script will not use persistent connections. support for fastcgi will help that. clients that support keepalive can use one tcp connection for all commands during clone and pull. this makes latency of binary search during pull much lower over wan. if server does not know content-length, it will force connection to close at end. right fix is to use chunked transfer-encoding but this is easier and does not hurt performance. only command that is affected is "changegroup" which is always last command during a pull.
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Thu, 15 Jun 2006 12:55:58 -0700
parents ffc3b2f1ab6a
children 01b856927970
line wrap: on
line diff
--- a/mercurial/hgweb/server.py
+++ b/mercurial/hgweb/server.py
@@ -27,6 +27,7 @@ def _splitURI(uri):
 
 class _hgwebhandler(object, BaseHTTPServer.BaseHTTPRequestHandler):
     def __init__(self, *args, **kargs):
+        self.protocol_version = 'HTTP/1.1'
         BaseHTTPServer.BaseHTTPRequestHandler.__init__(self, *args, **kargs)
 
     def log_error(self, format, *args):
@@ -85,7 +86,7 @@ class _hgwebhandler(object, BaseHTTPServ
 
         req = hgrequest(self.rfile, self.wfile, env)
         self.send_response(200, "Script output follows")
-        self.server.make_and_run_handler(req)
+        self.close_connection = self.server.make_and_run_handler(req)
 
 def create_server(ui, repo):
     use_threads = True
@@ -135,6 +136,7 @@ def create_server(ui, repo):
             else:
                 raise hg.RepoError(_('no repo found'))
             hgwebobj.run(req)
+            return req.will_close
 
     class IPv6HTTPServer(MercurialHTTPServer):
         address_family = getattr(socket, 'AF_INET6', None)