Patchwork D5498: server: always close http socket if responding with an error (issue6033)

login
register
mail settings
Submitter phabricator
Date Jan. 7, 2019, 7:17 p.m.
Message ID <424d206a8185541620db3e32bbbab4cb@localhost.localdomain>
Download mbox | patch
Permalink /patch/37543/
State Not Applicable
Headers show

Comments

phabricator - Jan. 7, 2019, 7:17 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG197f092b2cd9: server: always close http socket if responding with an error (issue6033) (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5498?vs=13020&id=13062

REVISION DETAIL
  https://phab.mercurial-scm.org/D5498

AFFECTED FILES
  mercurial/hgweb/server.py

CHANGE DETAILS




To: durin42, #hg-reviewers, mharbison72, pulkit
Cc: mharbison72, mercurial-devel

Patch

diff --git a/mercurial/hgweb/server.py b/mercurial/hgweb/server.py
--- a/mercurial/hgweb/server.py
+++ b/mercurial/hgweb/server.py
@@ -127,6 +127,13 @@ 
             and not path.startswith(self.server.prefix + b'/')):
             self._start_response(pycompat.strurl(common.statusmessage(404)),
                                  [])
+            if self.command == 'POST':
+                # Paranoia: tell the client we're going to close the
+                # socket so they don't try and reuse a socket that
+                # might have a POST body waiting to confuse us. We do
+                # this by directly munging self.saved_headers because
+                # self._start_response ignores Connection headers.
+                self.saved_headers = [(r'Connection', r'Close')]
             self._write(b"Not Found")
             self._done()
             return