comparison mercurial/hgweb/webcommands.py @ 49928: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
comparison
equal deleted inserted replaced
49927:e0c0545e2e55 49928:fda5a4b853ab
1297 if list(web.res.sendresponse()): 1297 if list(web.res.sendresponse()):
1298 raise error.ProgrammingError( 1298 raise error.ProgrammingError(
1299 b'sendresponse() should not emit data if writing later' 1299 b'sendresponse() should not emit data if writing later'
1300 ) 1300 )
1301 1301
1302 if web.req.method == b'HEAD':
1303 return []
1304
1302 bodyfh = web.res.getbodyfile() 1305 bodyfh = web.res.getbodyfile()
1303 1306
1304 archival.archive( 1307 archival.archive(
1305 web.repo, 1308 web.repo,
1306 bodyfh, 1309 bodyfh,