[PATCH 1 of 3 stable] hgweb: force connection close on early response

Augie Fackler raf at durin42.com
Wed Jul 24 21:07:27 UTC 2013


# HG changeset patch
# User Augie Fackler <raf at durin42.com>
# Date 1368322815 18000
#      Sat May 11 20:40:15 2013 -0500
# Branch stable
# Node ID 54ff8d5ce7107ac20c38cd85527968e2f540806e
# Parent  32e502b26983eaa89574835a024a9b035ad72bf4
hgweb: force connection close on early response

Not all WSGI servers close the socket when an early response is sent
to a large POST request, which can cause the server to interpret the
already-sent request body as an incoming (but hopelessly invalid)
request.

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
@@ -176,6 +176,8 @@
                                  '').lower() != '100-continue') or
                     req.env.get('X-HgHttp2', '')):
                     req.drain()
+                else:
+                    req.headers.append(('Connection', 'Close'))
                 req.respond(inst, protocol.HGTYPE,
                             body='0\n%s\n' % inst.message)
                 return ''



More information about the Mercurial-devel mailing list