hgweb: store the raw WSGI environment dict
authorGregory Szorc <gregory.szorc@gmail.com>
Sun, 11 Mar 2018 16:19:20 -0700
changeset 36909 84110a1d0f7d
parent 36908 cd6ae9ab7bd8
child 36910 98487ad0cf8b
hgweb: store the raw WSGI environment dict We need this so we can construct a new request instance from the original dict. Differential Revision: https://phab.mercurial-scm.org/D2831
mercurial/hgweb/hgweb_mod.py
mercurial/hgweb/request.py
--- a/mercurial/hgweb/hgweb_mod.py	Sun Mar 11 15:55:38 2018 -0700
+++ b/mercurial/hgweb/hgweb_mod.py	Sun Mar 11 16:19:20 2018 -0700
@@ -312,7 +312,7 @@
 
         # This state is global across all threads.
         encoding.encoding = rctx.config('web', 'encoding')
-        rctx.repo.ui.environ = wsgireq.env
+        rctx.repo.ui.environ = req.rawenv
 
         if rctx.csp:
             # hgwebdir may have added CSP header. Since we generate our own,
--- a/mercurial/hgweb/request.py	Sun Mar 11 15:55:38 2018 -0700
+++ b/mercurial/hgweb/request.py	Sun Mar 11 16:19:20 2018 -0700
@@ -149,6 +149,8 @@
     headers = attr.ib()
     # Request body input stream.
     bodyfh = attr.ib()
+    # WSGI environment dict, unmodified.
+    rawenv = attr.ib()
 
 def parserequestfromenv(env, bodyfh, reponame=None, altbaseurl=None):
     """Parse URL components from environment variables.
@@ -342,7 +344,8 @@
                          querystring=querystring,
                          qsparams=qsparams,
                          headers=headers,
-                         bodyfh=bodyfh)
+                         bodyfh=bodyfh,
+                         rawenv=env)
 
 class offsettrackingwriter(object):
     """A file object like object that is append only and tracks write count.