comparison mercurial/hgweb/hgweb_mod.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 642e31cb55f0
children 4077d6222cf1
comparison
equal deleted inserted replaced
49927:e0c0545e2e55 49928:fda5a4b853ab
228 mapfile, fp=fp, filters=filters, defaults=defaults, resources=tres 228 mapfile, fp=fp, filters=filters, defaults=defaults, resources=tres
229 ) 229 )
230 230
231 def sendtemplate(self, name, **kwargs): 231 def sendtemplate(self, name, **kwargs):
232 """Helper function to send a response generated from a template.""" 232 """Helper function to send a response generated from a template."""
233 kwargs = pycompat.byteskwargs(kwargs) 233 if self.req.method != b'HEAD':
234 self.res.setbodygen(self.tmpl.generate(name, kwargs)) 234 kwargs = pycompat.byteskwargs(kwargs)
235 self.res.setbodygen(self.tmpl.generate(name, kwargs))
235 return self.res.sendresponse() 236 return self.res.sendresponse()
236 237
237 238
238 class hgweb: 239 class hgweb:
239 """HTTP server for individual repositories. 240 """HTTP server for individual repositories.