http2: send an extra header to signal a non-broken client stable
authorAugie Fackler <durin42@gmail.com>
Wed, 27 Jul 2011 18:35:35 -0500
branchstable
changeset 14991 4f39610996fa
parent 14990 494b26ad8736
child 14992 188936b334b1
http2: send an extra header to signal a non-broken client Some proxies strip the expect header because they forward requests in a non-compliant way or as a way to defend against bogus clients.
mercurial/hgweb/hgweb_mod.py
mercurial/httprepo.py
--- a/mercurial/hgweb/hgweb_mod.py	Fri Jul 29 12:46:45 2011 -0500
+++ b/mercurial/hgweb/hgweb_mod.py	Wed Jul 27 18:35:35 2011 -0500
@@ -129,8 +129,9 @@
                 # 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.env.get('HTTP_EXPECT',
+                                 '').lower() != '100-continue') or
+                    req.env.get('X-HgHttp2', '')):
                     req.drain()
                 req.respond(inst, protocol.HGTYPE)
                 return '0\n%s\n' % inst.message
--- a/mercurial/httprepo.py	Fri Jul 29 12:46:45 2011 -0500
+++ b/mercurial/httprepo.py	Wed Jul 27 18:35:35 2011 -0500
@@ -78,6 +78,7 @@
 
         if data and self.ui.configbool('ui', 'usehttp2', False):
             headers['Expect'] = '100-Continue'
+            headers['X-HgHttp2'] = '1'
 
         self.ui.debug("sending %s command\n" % cmd)
         q = [('cmd', cmd)]