Augie Fackler <augie@google.com> [Mon, 26 Feb 2018 00:50:57 -0500] rev 36461
wireproto: use %d to encode an int, not a %s
Differential Revision: https://phab.mercurial-scm.org/D2449
Augie Fackler <augie@google.com> [Mon, 26 Feb 2018 00:50:35 -0500] rev 36460
httppeer: explicitly catch urlerr.httperror and re-raise
On Python 3 it seems urllib.error.HTTPError doesn't set the .args
field of the exception to have any contents, which then breaks our
socket.error catch. This works around that issue.
Differential Revision: https://phab.mercurial-scm.org/D2448
Augie Fackler <augie@google.com> [Mon, 26 Feb 2018 00:49:33 -0500] rev 36459
hgweb: pass exception message to builtin Exception ctor as sysstr
If we don't do this, the bytes gets repr()ed on Python 3 and we get
bogus error strings sent to clients. Ick.
Differential Revision: https://phab.mercurial-scm.org/D2447
Augie Fackler <augie@google.com> [Mon, 26 Feb 2018 00:28:10 -0500] rev 36458
bundle2: part id is an int, use %d to make it bytes
Differential Revision: https://phab.mercurial-scm.org/D2446
Augie Fackler <augie@google.com> [Mon, 26 Feb 2018 00:27:47 -0500] rev 36457
bundle2: **strkwargs love on various kwargs constructions
Differential Revision: https://phab.mercurial-scm.org/D2445
Augie Fackler <augie@google.com> [Sun, 25 Feb 2018 23:51:32 -0500] rev 36456
http: drop custom http client logic
Eight and a half years ago, as my starter bug on code.google.com, I
investigated a mysterious "broken pipe" error from seemingly random
clients[0]. That investigation revealed a tragic story: the Python
standard library's httplib was (and remains) barely functional. During
large POSTs, if a server responds early with an error (even a
permission denied error!) the client only notices that the server
closed the connection and everything breaks. Such server behavior is
implicitly legal under RFC 2616 (the latest HTTP RFC as of when I was
last working on this), and my understanding is that later RFCs have
made it explicitly legal to respond early with any status code outside
the 2xx range.
I embarked, probably foolishly, on a journey to write a new http
library with better overall behavior. The http library appears to work
well in most cases, but it can get confused in the presence of
proxies, and it depends on select(2) which limits its utility if a lot
of file descriptors are open. I haven't touched the http library in
almost two years, and in the interim the Python community has
discovered a better way[1] of writing network code. In theory some day
urllib3 will have its own home-grown http library built on h11[2], or
we could do that. Either way, it's time to declare our current
confusingly-named "http2" client logic and move on. I do hope to
revisit this some day: it's still garbage that we can't even respond
with a 401 or 403 without reading the entire POST body from the
client, but the goalposts on writing a new http client library have
moved substantially. We're almost certainly better off just switching
to requests and eventually picking up their http fixes than trying to
live with something that realistically only we'll ever use. Another
approach would be to write an adapter so that Mercurial can use pycurl
if it's installed. Neither of those approaches seem like they should
be investigated prior to a release of Mercurial that works on Python
3: that's where the mindshare is going to be for any improvements to
the state of the http client art.
0: http://web.archive.org/web/20130501031801/http://code.google.com/p/support/issues/detail?id=2716
1: http://sans-io.readthedocs.io/
2: https://github.com/njsmith/h11
Differential Revision: https://phab.mercurial-scm.org/D2444
Augie Fackler <augie@google.com> [Sun, 25 Feb 2018 23:34:58 -0500] rev 36455
statichttprepo: move HTTPRangeHandler from byterange and delete the latter
It turns out we've been toting around 472 lines of Python just for
this 20-ish line class that teaches urllib how to handle '206 Partial
Content'. byterange.py showed up in my \sstr\( Python 3 dragnet, and
found itself having overstayed its welcome in our codebase.
# no-check-commit because we're moving code that has to have foo_bar naming.
Differential Revision: https://phab.mercurial-scm.org/D2443