Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/server.py @ 41023:197f092b2cd9 stable 4.8.2
server: always close http socket if responding with an error (issue6033)
It's possible for hgweb to respond _very_ early with an error if we're
catching certain types of errors. When we do, we need to tell the client
the socket is toast when there's a POST involved because otherwise there
can be lingering POST data on the socket that will confuse any future
requests on the socket. This manifested as a flaky failure on Linux in an
lfs extension test and a reliable failure on FreeBSD. With this patch
applied, test-lfs-serve-access.t now passes for me on FreeBSD.
Differential Revision: https://phab.mercurial-scm.org/D5498
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Sun, 06 Jan 2019 14:58:54 -0500 |
parents | 8c7ecd32ccce |
children | 074c72a38423 |
comparison
equal
deleted
inserted
replaced
41022:481249481392 | 41023:197f092b2cd9 |
---|---|
125 # Ensure the slicing of path below is valid | 125 # Ensure the slicing of path below is valid |
126 if (path != self.server.prefix | 126 if (path != self.server.prefix |
127 and not path.startswith(self.server.prefix + b'/')): | 127 and not path.startswith(self.server.prefix + b'/')): |
128 self._start_response(pycompat.strurl(common.statusmessage(404)), | 128 self._start_response(pycompat.strurl(common.statusmessage(404)), |
129 []) | 129 []) |
130 if self.command == 'POST': | |
131 # Paranoia: tell the client we're going to close the | |
132 # socket so they don't try and reuse a socket that | |
133 # might have a POST body waiting to confuse us. We do | |
134 # this by directly munging self.saved_headers because | |
135 # self._start_response ignores Connection headers. | |
136 self.saved_headers = [(r'Connection', r'Close')] | |
130 self._write(b"Not Found") | 137 self._write(b"Not Found") |
131 self._done() | 138 self._done() |
132 return | 139 return |
133 | 140 |
134 env = {} | 141 env = {} |