[PATCH 2 of 2] http protocol: don't drain POST body if client used 100-continue

Augie Fackler durin42 at gmail.com
Sat Oct 9 08:28:01 CDT 2010


# HG changeset patch
# User Augie Fackler <durin42 at gmail.com>
# Date 1265407513 21600
# Node ID b965ae68792693d6a9acd3ba4c162f0fbaae8daf
# Parent  eabfcde6ea8b7df7245a0d51bcad7dfcf430a474
http protocol: don't drain POST body if client used 100-continue

This prevents double-sending a POST body. A new requirement is not
required because we're already explicitly declaring the expectation of
100-continue in the header, and conformant implementations of
100-continue must send the response after a brief delay if the server
doesn't respond with a final status or continue.

diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py
+++ b/mercurial/hgweb/hgweb_mod.py
@@ -117,9 +117,11 @@
                 raise ErrorResponse(HTTP_NOT_FOUND)
             if cmd in perms:
                 try:
+                    expectcont = (
+                        req.env.get('HTTP_EXPECT', '') == '100-Continue')
                     self.check_perm(req, perms[cmd])
                 except ErrorResponse, inst:
-                    if cmd == 'unbundle':
+                    if cmd == 'unbundle' and not expectcont:
                         req.drain()
                     req.respond(inst, protocol.HGTYPE)
                     return '0\n%s\n' % inst.message


More information about the Mercurial-devel mailing list