diff -r 2859c6fa4fc2 -r a88d68dc3ee8 mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py Sat Mar 10 11:15:05 2018 -0800 +++ b/mercurial/hgweb/hgweb_mod.py Sat Mar 10 11:23:05 2018 -0800 @@ -305,6 +305,7 @@ def _runwsgi(self, wsgireq, repo): req = wsgireq.req + res = wsgireq.res rctx = requestcontext(self, repo) # This state is global across all threads. @@ -317,11 +318,12 @@ wsgireq.headers = [h for h in wsgireq.headers if h[0] != 'Content-Security-Policy'] wsgireq.headers.append(('Content-Security-Policy', rctx.csp)) + res.headers['Content-Security-Policy'] = rctx.csp - handled, res = wireprotoserver.handlewsgirequest( - rctx, wsgireq, req, self.check_perm) + handled = wireprotoserver.handlewsgirequest( + rctx, wsgireq, req, res, self.check_perm) if handled: - return res + return res.sendresponse() if req.havepathinfo: query = req.dispatchpath