hgweb: assign ctype to requestcontext
authorGregory Szorc <gregory.szorc@gmail.com>
Sat, 22 Aug 2015 17:08:37 -0700
changeset 26211 ea489d94e1dc
parent 26210 7c759f1a056f
child 26212 0d8df1f510c6
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.
mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py	Sat Aug 22 17:04:24 2015 -0700
+++ b/mercurial/hgweb/hgweb_mod.py	Sat Aug 22 17:08:37 2015 -0700
@@ -398,7 +398,8 @@
                 msg = 'no such method: %s' % cmd
                 raise ErrorResponse(HTTP_BAD_REQUEST, msg)
             elif cmd == 'file' and 'raw' in req.form.get('style', []):
-                self.ctype = ctype
+                # TODO convert to regular assignment once app proxy is removed.
+                object.__setattr__(rctx, 'ctype', ctype)
                 content = webcommands.rawfile(rctx, req, tmpl)
             else:
                 content = getattr(webcommands, cmd)(rctx, req, tmpl)