Mercurial > hg
diff mercurial/hgweb/server.py @ 39954:8c7ecd32ccce
py3: use system strings in HTTP server code
Previously the source transformer was converting some string literals
to bytes and we were comparing a system native string to bytes
and this was leading to sending the wrong HTTP response headers on
Python 3.
After this change, we now properly send Transfer-Encoding and
Connection response headers on Python 3.
Differential Revision: https://phab.mercurial-scm.org/D4833
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 01 Oct 2018 23:12:42 -0700 |
parents | d1e0b905c59d |
children | 348352658e4b 197f092b2cd9 |
line wrap: on
line diff
--- a/mercurial/hgweb/server.py Mon Oct 01 23:39:49 2018 -0700 +++ b/mercurial/hgweb/server.py Mon Oct 01 23:12:42 2018 -0700 @@ -205,12 +205,12 @@ self._chunked = False for h in self.saved_headers: self.send_header(*h) - if h[0].lower() == 'content-length': + if h[0].lower() == r'content-length': self.length = int(h[1]) if (self.length is None and saved_status[0] != common.HTTP_NOT_MODIFIED): self._chunked = (not self.close_connection and - self.request_version == "HTTP/1.1") + self.request_version == r'HTTP/1.1') if self._chunked: self.send_header(r'Transfer-Encoding', r'chunked') else: @@ -223,7 +223,7 @@ code, msg = http_status.split(None, 1) code = int(code) self.saved_status = http_status - bad_headers = ('connection', 'transfer-encoding') + bad_headers = (r'connection', r'transfer-encoding') self.saved_headers = [h for h in headers if h[0].lower() not in bad_headers] return self._write