Mercurial > public > mercurial-scm > hg
diff mercurial/hgweb/webcommands.py @ 49846:fda5a4b853ab
hgweb: skip body creation of HEAD for most requests
The body is thrown away anyway, so this just wastes a lot of CPU time.
In the case of /archive/, this skips manifest processing and the actual
file archiving, resulting in a huge difference.
The most tricky part here is skipping the Content-Length creation as it
would indicate the output size for the corresponding GET request.
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Fri, 16 Dec 2022 17:46:20 +0100 |
parents | d44e3c45f0e4 |
children | d8c8a923ee9b |
line wrap: on
line diff
--- a/mercurial/hgweb/webcommands.py Wed Jan 04 16:02:22 2023 +0100 +++ b/mercurial/hgweb/webcommands.py Fri Dec 16 17:46:20 2022 +0100 @@ -1299,6 +1299,9 @@ b'sendresponse() should not emit data if writing later' ) + if web.req.method == b'HEAD': + return [] + bodyfh = web.res.getbodyfile() archival.archive(