Mercurial > public > mercurial-scm > hg
diff mercurial/hgweb/hgweb_mod.py @ 5890:a0e20a5eba3c
hgweb: fast path for sending raw files
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Fri, 18 Jan 2008 19:53:38 +0100 |
parents | 209577095f20 |
children | d0576d065993 |
line wrap: on
line diff
--- a/mercurial/hgweb/hgweb_mod.py Fri Jan 18 19:53:38 2008 +0100 +++ b/mercurial/hgweb/hgweb_mod.py Fri Jan 18 19:53:38 2008 +0100 @@ -206,12 +206,17 @@ method = getattr(protocol, cmd) method(self, req) else: + tmpl = self.templater(req) if cmd == '': req.form['cmd'] = [tmpl.cache['default']] cmd = req.form['cmd'][0] - method = getattr(webcommands, cmd) - method(self, req, tmpl) + + if cmd == 'file' and 'raw' in req.form['style']: + webcommands.rawfile(self, req, tmpl) + else: + getattr(webcommands, cmd)(self, req, tmpl) + del tmpl except revlog.LookupError, err: @@ -254,12 +259,6 @@ req.header(msg.items()) yield header_file.read() - def rawfileheader(**map): - req.header([('Content-type', map['mimetype']), - ('Content-disposition', 'filename=%s' % map['file']), - ('Content-length', str(len(map['raw'])))]) - yield '' - def footer(**map): yield tmpl("footer", **map) @@ -300,7 +299,6 @@ "header": header, "footer": footer, "motd": motd, - "rawfileheader": rawfileheader, "sessionvars": sessionvars }) return tmpl