##// END OF EJS Templates
hgweb: fix decodevaluefromheaders to always return a bytes value...
Augie Fackler -
r34745:0a2ef612 default
parent child Browse files
Show More
@@ -30,15 +30,18 b" 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)
General Comments 0
You need to be logged in to leave comments. Login now