comparison mercurial/hgweb/request.py @ 34514:528b21b853aa

request: coerce content-type to native str Again, required by WSGI. Differential Revision: https://phab.mercurial-scm.org/D969
author Augie Fackler <augie@google.com>
date Thu, 05 Oct 2017 14:27:21 -0400
parents 34fcb0f66837
children 95be8928d6b2
comparison
equal deleted inserted replaced
34513:34fcb0f66837 34514:528b21b853aa
17 HTTP_NOT_MODIFIED, 17 HTTP_NOT_MODIFIED,
18 statusmessage, 18 statusmessage,
19 ) 19 )
20 20
21 from .. import ( 21 from .. import (
22 pycompat,
22 util, 23 util,
23 ) 24 )
24 25
25 shortcuts = { 26 shortcuts = {
26 'cl': [('cmd', ['changelog']), ('rev', None)], 27 'cl': [('cmd', ['changelog']), ('rev', None)],
87 length = int(self.env.get('CONTENT_LENGTH') or 0) 88 length = int(self.env.get('CONTENT_LENGTH') or 0)
88 for s in util.filechunkiter(self.inp, limit=length): 89 for s in util.filechunkiter(self.inp, limit=length):
89 pass 90 pass
90 91
91 def respond(self, status, type, filename=None, body=None): 92 def respond(self, status, type, filename=None, body=None):
93 if not isinstance(type, str):
94 type = pycompat.sysstr(type)
92 if self._start_response is not None: 95 if self._start_response is not None:
93 self.headers.append(('Content-Type', type)) 96 self.headers.append(('Content-Type', type))
94 if filename: 97 if filename:
95 filename = (filename.rpartition('/')[-1] 98 filename = (filename.rpartition('/')[-1]
96 .replace('\\', '\\\\').replace('"', '\\"')) 99 .replace('\\', '\\\\').replace('"', '\\"'))