hgweb: propagate http headers from ErrorResponse for web interface commands
authorSune Foldager <cryo@cyanite.org>
Thu, 14 Jun 2018 13:44:42 +0200
changeset 38316 519b46a8f4d2
parent 38315 523f64466a05
child 38317 068e774ae29e
hgweb: propagate http headers from ErrorResponse for web interface commands This makes it possible for e.g. authorization hooks to provide appropriate headers to make the web browser ask for credentials. It's done in the same way as the existing code in wireprotoserver.py.
mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py	Thu Jun 14 20:29:27 2018 +0900
+++ b/mercurial/hgweb/hgweb_mod.py	Thu Jun 14 13:44:42 2018 +0200
@@ -441,6 +441,8 @@
             res.headers['Content-Type'] = ctype
             return rctx.sendtemplate('error', error=pycompat.bytestr(e))
         except ErrorResponse as e:
+            for k, v in e.headers:
+                res.headers[k] = v
             res.status = statusmessage(e.code, pycompat.bytestr(e))
             res.headers['Content-Type'] = ctype
             return rctx.sendtemplate('error', error=pycompat.bytestr(e))