Mercurial > hg
diff mercurial/hgweb/server.py @ 36802:7fc80c982656
hgweb: ensure all wsgi environment values are str
Previously, we had a few entries that were bytes on Python 3.
PEP-0333 states that all entries must be the native str type
(bytes on Python 2, str on Python 3).
This required a number of changes to hgweb_mod to unbreak
things on Python 3. I suspect there still may be some regressions.
I'm going to introduce a data structure that represents a parsed
WSGI request in upcoming commits. This will hold bytes and will
allow us to stop using raw literals throughout the WSGI code.
Differential Revision: https://phab.mercurial-scm.org/D2730
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 08 Mar 2018 09:26:51 -0800 |
parents | bf9a04d78084 |
children | 8e1556ac01bb |
line wrap: on
line diff
--- a/mercurial/hgweb/server.py Wed Mar 07 16:18:52 2018 -0800 +++ b/mercurial/hgweb/server.py Thu Mar 08 09:26:51 2018 -0800 @@ -124,8 +124,8 @@ env[r'SERVER_NAME'] = self.server.server_name env[r'SERVER_PORT'] = str(self.server.server_port) env[r'REQUEST_URI'] = self.path - env[r'SCRIPT_NAME'] = self.server.prefix - env[r'PATH_INFO'] = path[len(self.server.prefix):] + env[r'SCRIPT_NAME'] = pycompat.sysstr(self.server.prefix) + env[r'PATH_INFO'] = pycompat.sysstr(path[len(self.server.prefix):]) env[r'REMOTE_HOST'] = self.client_address[0] env[r'REMOTE_ADDR'] = self.client_address[0] if query: @@ -154,7 +154,7 @@ env[hkey] = hval env[r'SERVER_PROTOCOL'] = self.request_version env[r'wsgi.version'] = (1, 0) - env[r'wsgi.url_scheme'] = self.url_scheme + env[r'wsgi.url_scheme'] = pycompat.sysstr(self.url_scheme) if env.get(r'HTTP_EXPECT', '').lower() == '100-continue': self.rfile = common.continuereader(self.rfile, self.wfile.write)