Patchwork hgweb: propagate http headers from ErrorResponse for web interface commands

login
register
mail settings
Submitter Sune Foldager
Date June 14, 2018, 11:46 a.m.
Message ID <d81af9ddf782d3761e89.1528976776@firefly.edlund.dk>
Download mbox | patch
Permalink /patch/32129/
State Accepted
Headers show

Comments

Sune Foldager - June 14, 2018, 11:46 a.m.
# HG changeset patch
# User Sune Foldager <cryo@cyanite.org>
# Date 1528976682 -7200
#      Thu Jun 14 13:44:42 2018 +0200
# Node ID d81af9ddf782d3761e89f778d42756b91514d1cc
# Parent  c07424ec633c2541136a1b35dbcea1b3243dc1c1
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.
Augie Fackler - June 14, 2018, 3:07 p.m.
> On Jun 14, 2018, at 07:46, Sune Foldager <sune.foldager@me.com> wrote:
> 
> # HG changeset patch
> # User Sune Foldager <cryo@cyanite.org>
> # Date 1528976682 -7200
> #      Thu Jun 14 13:44:42 2018 +0200
> # Node ID d81af9ddf782d3761e89f778d42756b91514d1cc
> # Parent  c07424ec633c2541136a1b35dbcea1b3243dc1c1
> hgweb: propagate http headers from ErrorResponse for web interface commands

queued this, thanks!

Patch

diff -r c07424ec633c -r d81af9ddf782 mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py	Tue Jun 12 12:41:09 2018 -0700
+++ 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))