# HG changeset patch # User Gregory Szorc # Date 2018-03-11 22:40:58 # Node ID c1de7efca5745741275295ed735d039355215a2e # Parent 6a0e4efbc61e8aaceee8de79444927ca6e5d147e hgweb: port to new response API These were the last consumers of wsgirequest.respond() \o/ Differential Revision: https://phab.mercurial-scm.org/D2829 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 ..i18n import _ from .common import ( ErrorResponse, - HTTP_NOT_FOUND, HTTP_SERVER_ERROR, cspvalues, get_contact, @@ -23,6 +22,7 @@ from .common import ( ismember, paritygen, staticfile, + statusmessage, ) from .. import ( @@ -31,6 +31,7 @@ from .. import ( error, hg, profiling, + pycompat, scmutil, templater, ui as uimod, @@ -442,12 +443,14 @@ class hgwebdir(object): 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