Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/protocol.py @ 34744:0a2ef612ad50
hgweb: fix decodevaluefromheaders to always return a bytes value
That's more in line with what we want, and we know it's ASCII data
since that's all HTTP technically allows in headers anyway.
Differential Revision: https://phab.mercurial-scm.org/D1112
author | Augie Fackler <augie@google.com> |
---|---|
date | Sun, 15 Oct 2017 00:43:01 -0400 |
parents | dc2bf7074147 |
children | 8cdb671dbd0b |
comparison
equal
deleted
inserted
replaced
34743:dc2bf7074147 | 34744:0a2ef612ad50 |
---|---|
28 HGTYPE = 'application/mercurial-0.1' | 28 HGTYPE = 'application/mercurial-0.1' |
29 HGTYPE2 = 'application/mercurial-0.2' | 29 HGTYPE2 = 'application/mercurial-0.2' |
30 HGERRTYPE = 'application/hg-error' | 30 HGERRTYPE = 'application/hg-error' |
31 | 31 |
32 def decodevaluefromheaders(req, headerprefix): | 32 def decodevaluefromheaders(req, headerprefix): |
33 """Decode a long value from multiple HTTP request headers.""" | 33 """Decode a long value from multiple HTTP request headers. |
34 | |
35 Returns the value as a bytes, not a str. | |
36 """ | |
34 chunks = [] | 37 chunks = [] |
35 i = 1 | 38 i = 1 |
39 prefix = headerprefix.upper().replace(r'-', r'_') | |
36 while True: | 40 while True: |
37 v = req.env.get('HTTP_%s_%d' % ( | 41 v = req.env.get(r'HTTP_%s_%d' % (prefix, i)) |
38 headerprefix.upper().replace('-', '_'), i)) | |
39 if v is None: | 42 if v is None: |
40 break | 43 break |
41 chunks.append(v) | 44 chunks.append(pycompat.bytesurl(v)) |
42 i += 1 | 45 i += 1 |
43 | 46 |
44 return ''.join(chunks) | 47 return ''.join(chunks) |
45 | 48 |
46 class webproto(wireproto.abstractserverproto): | 49 class webproto(wireproto.abstractserverproto): |