Mercurial > public > mercurial-scm > hg-stable
diff mercurial/hgweb/protocol.py @ 33842:3c91cc0c5fde
httppeer: add support for httppostargs when we're sending a file
This is probably only used in the 'unbundle' command, but the code
ended up being cleaner to make it generic and treat *all* httppostargs
with a non-args request body as though they were file-like in
nature. It also means we get test coverage more or less for free. A
previous version of this change didn't use io.BytesIO, and it was a
lot more complicated.
This also fixes a server-side bug, so anyone using httppostargs should
update all of their servers to this revision or later *before* this
gets to their clients, otherwise servers will hang trying to over-read
the POST body.
Differential Revision: https://phab.mercurial-scm.org/D231
author | Augie Fackler <augie@google.com> |
---|---|
date | Wed, 26 Jul 2017 17:58:19 -0400 |
parents | 35c233975b78 |
children | e21f274cccea |
line wrap: on
line diff
--- a/mercurial/hgweb/protocol.py Tue Aug 15 21:09:33 2017 +0900 +++ b/mercurial/hgweb/protocol.py Wed Jul 26 17:58:19 2017 -0400 @@ -75,6 +75,9 @@ return args def getfile(self, fp): length = int(self.req.env['CONTENT_LENGTH']) + # If httppostargs is used, we need to read Content-Length + # minus the amount that was consumed by args. + length -= int(self.req.env.get('HTTP_X_HGARGS_POST', 0)) for s in util.filechunkiter(self.req, limit=length): fp.write(s) def redirect(self):