comparison mercurial/hgweb/hgweb_mod.py @ 26211:ea489d94e1dc

hgweb: assign ctype to requestcontext The very existence of ctype is a bit hacky. But we roll with it. Before this patch, there was possibly a race condition between 2 threads handling file requests: 1 thread could set the ctype and another serving a different file would read and use that potentially wrong ctype.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 22 Aug 2015 17:08:37 -0700
parents 7c759f1a056f
children 0d0a0837895d
comparison
equal deleted inserted replaced
26210:7c759f1a056f 26211:ea489d94e1dc
396 caching(self, req) # sets ETag header or raises NOT_MODIFIED 396 caching(self, req) # sets ETag header or raises NOT_MODIFIED
397 if cmd not in webcommands.__all__: 397 if cmd not in webcommands.__all__:
398 msg = 'no such method: %s' % cmd 398 msg = 'no such method: %s' % cmd
399 raise ErrorResponse(HTTP_BAD_REQUEST, msg) 399 raise ErrorResponse(HTTP_BAD_REQUEST, msg)
400 elif cmd == 'file' and 'raw' in req.form.get('style', []): 400 elif cmd == 'file' and 'raw' in req.form.get('style', []):
401 self.ctype = ctype 401 # TODO convert to regular assignment once app proxy is removed.
402 object.__setattr__(rctx, 'ctype', ctype)
402 content = webcommands.rawfile(rctx, req, tmpl) 403 content = webcommands.rawfile(rctx, req, tmpl)
403 else: 404 else:
404 content = getattr(webcommands, cmd)(rctx, req, tmpl) 405 content = getattr(webcommands, cmd)(rctx, req, tmpl)
405 req.respond(HTTP_OK, ctype) 406 req.respond(HTTP_OK, ctype)
406 407