Patchwork [03,of,12] hgweb: use Content-Length for pushres

login
register
mail settings
Submitter Mads Kiilerich
Date Jan. 11, 2013, 11:32 p.m.
Message ID <3de07b9123f7babdbd11.1357947167@mk-desktop>
Download mbox | patch
Permalink /patch/563/
State Accepted
Commit 6c2563b2c1c6a2d92a6bb712be2e04c345a2a1d6
Headers show

Comments

Mads Kiilerich - Jan. 11, 2013, 11:32 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1357947109 -3600
# Node ID 3de07b9123f7babdbd11958e4ddca94a91e9a228
# Parent  4f58d5f65b70b060df3f76cfe72a6716a69a40b6
hgweb: use Content-Length for pushres

This prevents some unnecessary http connection close.

Patch

diff --git a/mercurial/hgweb/protocol.py b/mercurial/hgweb/protocol.py
--- a/mercurial/hgweb/protocol.py
+++ b/mercurial/hgweb/protocol.py
@@ -82,8 +82,9 @@ 
         return rsp.gen
     elif isinstance(rsp, wireproto.pushres):
         val = p.restore()
-        req.respond(HTTP_OK, HGTYPE)
-        return ['%d\n%s' % (rsp.res, val)]
+        rsp = '%d\n%s' % (rsp.res, val)
+        req.respond(HTTP_OK, HGTYPE, length=len(rsp))
+        return [rsp]
     elif isinstance(rsp, wireproto.pusherr):
         # drain the incoming bundle
         req.drain()
diff --git a/tests/test-push-cgi.t b/tests/test-push-cgi.t
--- a/tests/test-push-cgi.t
+++ b/tests/test-push-cgi.t
@@ -54,6 +54,7 @@ 
   $ cat page2
   Status: 200 Script output follows\r (esc)
   Content-Type: application/mercurial-0.1\r (esc)
+  Content-Length: 102\r (esc)
   \r (esc)
   1
   adding changesets
@@ -68,6 +69,7 @@ 
   $ cat page3
   Status: 200 Script output follows\r (esc)
   Content-Type: application/mercurial-0.1\r (esc)
+  Content-Length: 102\r (esc)
   \r (esc)
   1
   adding changesets
@@ -82,6 +84,7 @@ 
   $ cat page4
   Status: 200 Script output follows\r (esc)
   Content-Type: application/mercurial-0.1\r (esc)
+  Content-Length: 102\r (esc)
   \r (esc)
   1
   adding changesets