diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py --- a/mercurial/hgweb/hgwebdir_mod.py +++ b/mercurial/hgweb/hgwebdir_mod.py @@ -15,7 +15,6 @@ from .common import ( ErrorResponse, - HTTP_NOT_FOUND, HTTP_SERVER_ERROR, cspvalues, get_contact, @@ -23,6 +22,7 @@ ismember, paritygen, staticfile, + statusmessage, ) from .. import ( @@ -31,6 +31,7 @@ error, hg, profiling, + pycompat, scmutil, templater, ui as uimod, @@ -442,12 +443,14 @@ return self.makeindex(req, res, tmpl, subdir) # prefixes not found - wsgireq.respond(HTTP_NOT_FOUND, ctype) - return tmpl("notfound", repo=virtual) + res.status = '404 Not Found' + res.setbodygen(tmpl('notfound', repo=virtual)) + return res.sendresponse() - except ErrorResponse as err: - wsgireq.respond(err, ctype) - return tmpl('error', error=err.message or '') + except ErrorResponse as e: + res.status = statusmessage(e.code, pycompat.bytestr(e)) + res.setbodygen(tmpl('error', error=e.message or '')) + return res.sendresponse() finally: tmpl = None