# HG changeset patch # User Augie Fackler # Date 2013-05-12 01:40:15 # Node ID 60e060f4faa9941b65d2ad406d119dd92c5f13e7 # Parent 8cfa3a3664a5b9c5ec561df81516c1b19e690c7d 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 @@ class hgweb(object): '').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 ''