py3: convert HTTP request headers to str
authorGregory Szorc <gregory.szorc@gmail.com>
Mon, 01 Oct 2018 23:08:04 -0700
changeset 39955 c421c22d3ad2
parent 39954 8c7ecd32ccce
child 39956 36e9d2c60837
py3: convert HTTP request headers to str The low-level request object ideally takes system strings for HTTP request headers and values. If we send in bytes, it works. But a duplicate header check fails and various tests emit duplicate user-agent headers. Differential Revision: https://phab.mercurial-scm.org/D4834
mercurial/debugcommands.py
--- a/mercurial/debugcommands.py	Mon Oct 01 23:12:42 2018 -0700
+++ b/mercurial/debugcommands.py	Mon Oct 01 23:08:04 2018 -0700
@@ -3286,7 +3286,10 @@
                 line = line.lstrip()
                 m = re.match(b'^([a-zA-Z0-9_-]+): (.*)$', line)
                 if m:
-                    headers[m.group(1)] = m.group(2)
+                    # Headers need to use native strings.
+                    key = pycompat.strurl(m.group(1))
+                    value = pycompat.strurl(m.group(2))
+                    headers[key] = value
                     continue
 
                 if line.startswith(b'BODYFILE '):