comparison mercurial/hgweb/server.py @ 37591:b5ca5d34fe8d

hgweb: use native strings when interfacing with stdlib headers We're still parsing the stdlib-provided headers here, so we need to tread carefully and use native strings. Yuck. Differential Revision: https://phab.mercurial-scm.org/D3250
author Augie Fackler <augie@google.com>
date Wed, 11 Apr 2018 16:26:40 -0400
parents a2566597acb5
children ed5448edcbfa
comparison
equal deleted inserted replaced
37590:9170df9106a8 37591:b5ca5d34fe8d
137 if pycompat.ispy3: 137 if pycompat.ispy3:
138 if self.headers.get_content_type() is None: 138 if self.headers.get_content_type() is None:
139 env[r'CONTENT_TYPE'] = self.headers.get_default_type() 139 env[r'CONTENT_TYPE'] = self.headers.get_default_type()
140 else: 140 else:
141 env[r'CONTENT_TYPE'] = self.headers.get_content_type() 141 env[r'CONTENT_TYPE'] = self.headers.get_content_type()
142 length = self.headers.get('content-length') 142 length = self.headers.get(r'content-length')
143 else: 143 else:
144 if self.headers.typeheader is None: 144 if self.headers.typeheader is None:
145 env[r'CONTENT_TYPE'] = self.headers.type 145 env[r'CONTENT_TYPE'] = self.headers.type
146 else: 146 else:
147 env[r'CONTENT_TYPE'] = self.headers.typeheader 147 env[r'CONTENT_TYPE'] = self.headers.typeheader
148 length = self.headers.getheader('content-length') 148 length = self.headers.getheader(r'content-length')
149 if length: 149 if length:
150 env[r'CONTENT_LENGTH'] = length 150 env[r'CONTENT_LENGTH'] = length
151 for header in [h for h in self.headers.keys() 151 for header in [h for h in self.headers.keys()
152 if h not in ('content-type', 'content-length')]: 152 if h not in (r'content-type', r'content-length')]:
153 hkey = r'HTTP_' + header.replace(r'-', r'_').upper() 153 hkey = r'HTTP_' + header.replace(r'-', r'_').upper()
154 hval = self.headers.get(header) 154 hval = self.headers.get(header)
155 hval = hval.replace(r'\n', r'').strip() 155 hval = hval.replace(r'\n', r'').strip()
156 if hval: 156 if hval:
157 env[hkey] = hval 157 env[hkey] = hval