[PATCH 2 of 4 RFC] hgweb_mod: respond right away if the client specified 100-continue support

Augie Fackler durin42 at gmail.com
Wed Mar 9 09:55:30 CST 2011


# HG changeset patch
# User Augie Fackler <durin42 at gmail.com>
# Date 1294435161 21600
# Node ID 755fa87ed6990c898a0fb36bf5332e40fa1aa696
# Parent  4406299c2001ffad53c54f12da719e0ea6595134
hgweb_mod: respond right away if the client specified 100-continue support

Clients that send 100-continue should make sure they really support
continue intelligently. In a later patch we'll introduce a capability so
new clients don't pay a performance penalty talking to old servers.

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
@@ -121,7 +121,11 @@
                     self.check_perm(req, perms[cmd])
                 return protocol.call(self.repo, req, cmd)
             except ErrorResponse, inst:
-                if cmd == 'unbundle':
+                # A client that sends unbundle without 100-continue will
+                # break if we respond early.
+                if (cmd == 'unbundle' and
+                    req.env.get('HTTP_EXPECT', 
+                                '').lower() != '100-continue'):
                     req.drain()
                 req.respond(inst, protocol.HGTYPE)
                 return '0\n%s\n' % inst.message


More information about the Mercurial-devel mailing list