Mercurial > hg
diff mercurial/hgweb/hgwebdir_mod.py @ 36907:c1de7efca574
hgweb: port to new response API
These were the last consumers of wsgirequest.respond() \o/
Differential Revision: https://phab.mercurial-scm.org/D2829
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 11 Mar 2018 15:40:58 -0700 |
parents | 6a0e4efbc61e |
children | cd6ae9ab7bd8 |
line wrap: on
line diff
--- a/mercurial/hgweb/hgwebdir_mod.py Sun Mar 11 15:35:03 2018 -0700 +++ b/mercurial/hgweb/hgwebdir_mod.py Sun Mar 11 15:40:58 2018 -0700 @@ -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