[PATCH 03 of 12] hgweb: use Content-Length for pushres
Mads Kiilerich
mads at kiilerich.com
Fri Jan 11 17:32:47 CST 2013
# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1357947109 -3600
# Node ID 3de07b9123f7babdbd11958e4ddca94a91e9a228
# Parent 4f58d5f65b70b060df3f76cfe72a6716a69a40b6
hgweb: use Content-Length for pushres
This prevents some unnecessary http connection close.
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
More information about the Mercurial-devel
mailing list