Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/debugcommands.py @ 39956:c421c22d3ad2
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
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 01 Oct 2018 23:08:04 -0700 |
parents | 9c8eff5cfa1b |
children | 36e9d2c60837 |
comparison
equal
deleted
inserted
replaced
39955:8c7ecd32ccce | 39956:c421c22d3ad2 |
---|---|
3284 frames = [] | 3284 frames = [] |
3285 for line in lines: | 3285 for line in lines: |
3286 line = line.lstrip() | 3286 line = line.lstrip() |
3287 m = re.match(b'^([a-zA-Z0-9_-]+): (.*)$', line) | 3287 m = re.match(b'^([a-zA-Z0-9_-]+): (.*)$', line) |
3288 if m: | 3288 if m: |
3289 headers[m.group(1)] = m.group(2) | 3289 # Headers need to use native strings. |
3290 key = pycompat.strurl(m.group(1)) | |
3291 value = pycompat.strurl(m.group(2)) | |
3292 headers[key] = value | |
3290 continue | 3293 continue |
3291 | 3294 |
3292 if line.startswith(b'BODYFILE '): | 3295 if line.startswith(b'BODYFILE '): |
3293 with open(line.split(b' ', 1), 'rb') as fh: | 3296 with open(line.split(b' ', 1), 'rb') as fh: |
3294 body = fh.read() | 3297 body = fh.read() |