Mercurial > public > mercurial-scm > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
5889:209577095f20 | 5890:a0e20a5eba3c |
---|---|
204 cmd = req.form.get('cmd', [''])[0] | 204 cmd = req.form.get('cmd', [''])[0] |
205 if hasattr(protocol, cmd): | 205 if hasattr(protocol, cmd): |
206 method = getattr(protocol, cmd) | 206 method = getattr(protocol, cmd) |
207 method(self, req) | 207 method(self, req) |
208 else: | 208 else: |
209 | |
209 tmpl = self.templater(req) | 210 tmpl = self.templater(req) |
210 if cmd == '': | 211 if cmd == '': |
211 req.form['cmd'] = [tmpl.cache['default']] | 212 req.form['cmd'] = [tmpl.cache['default']] |
212 cmd = req.form['cmd'][0] | 213 cmd = req.form['cmd'][0] |
213 method = getattr(webcommands, cmd) | 214 |
214 method(self, req, tmpl) | 215 if cmd == 'file' and 'raw' in req.form['style']: |
216 webcommands.rawfile(self, req, tmpl) | |
217 else: | |
218 getattr(webcommands, cmd)(self, req, tmpl) | |
219 | |
215 del tmpl | 220 del tmpl |
216 | 221 |
217 except revlog.LookupError, err: | 222 except revlog.LookupError, err: |
218 req.respond(404, tmpl( | 223 req.respond(404, tmpl( |
219 'error', error='revision not found: %s' % err.name)) | 224 'error', error='revision not found: %s' % err.name)) |
252 ''.join(tmpl("header", encoding=self.encoding, **map))) | 257 ''.join(tmpl("header", encoding=self.encoding, **map))) |
253 msg = mimetools.Message(header_file, 0) | 258 msg = mimetools.Message(header_file, 0) |
254 req.header(msg.items()) | 259 req.header(msg.items()) |
255 yield header_file.read() | 260 yield header_file.read() |
256 | 261 |
257 def rawfileheader(**map): | |
258 req.header([('Content-type', map['mimetype']), | |
259 ('Content-disposition', 'filename=%s' % map['file']), | |
260 ('Content-length', str(len(map['raw'])))]) | |
261 yield '' | |
262 | |
263 def footer(**map): | 262 def footer(**map): |
264 yield tmpl("footer", **map) | 263 yield tmpl("footer", **map) |
265 | 264 |
266 def motd(**map): | 265 def motd(**map): |
267 yield self.config("web", "motd", "") | 266 yield self.config("web", "motd", "") |
298 "urlbase": urlbase, | 297 "urlbase": urlbase, |
299 "repo": self.reponame, | 298 "repo": self.reponame, |
300 "header": header, | 299 "header": header, |
301 "footer": footer, | 300 "footer": footer, |
302 "motd": motd, | 301 "motd": motd, |
303 "rawfileheader": rawfileheader, | |
304 "sessionvars": sessionvars | 302 "sessionvars": sessionvars |
305 }) | 303 }) |
306 return tmpl | 304 return tmpl |
307 | 305 |
308 def archivelist(self, nodeid): | 306 def archivelist(self, nodeid): |