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
--- 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 '):