Mercurial > public > mercurial-scm > hg-stable
diff mercurial/hgweb/hgwebdir_mod.py @ 6945:2cfdabe235fb
hgweb: return content iterator instead of using write() callable
This is a new version of 4879468fa28f (which was backed out in 943f066c0d58),
with an extra line removed to fix problems with hg serve. hg's internal web
server contains checking if the app isn't trying to write more bytes than
specified by the Content-Length header. The first try still contained an old
line that wrote the response, so the response was sent twice.
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Sat, 30 Aug 2008 17:13:23 +0200 |
parents | 580d5e6bfc1f |
children | 125c8fedcbe0 |
line wrap: on
line diff
--- a/mercurial/hgweb/hgwebdir_mod.py Fri Aug 29 16:50:11 2008 +0200 +++ b/mercurial/hgweb/hgwebdir_mod.py Sat Aug 30 17:13:23 2008 +0200 @@ -89,14 +89,12 @@ fname = virtual[7:] else: fname = req.form['static'][0] - req.write(staticfile(static, fname, req)) - return [] + return staticfile(static, fname, req) # top-level index elif not virtual: req.respond(HTTP_OK, ctype) - req.write(self.makeindex(req, tmpl)) - return [] + return ''.join(self.makeindex(req, tmpl)), # nested indexes and hgwebs @@ -118,8 +116,7 @@ subdir = virtual + '/' if [r for r in repos if r.startswith(subdir)]: req.respond(HTTP_OK, ctype) - req.write(self.makeindex(req, tmpl, subdir)) - return [] + return ''.join(self.makeindex(req, tmpl, subdir)), up = virtual.rfind('/') if up < 0: @@ -128,13 +125,11 @@ # prefixes not found req.respond(HTTP_NOT_FOUND, ctype) - req.write(tmpl("notfound", repo=virtual)) - return [] + return ''.join(tmpl("notfound", repo=virtual)), except ErrorResponse, err: req.respond(err.code, ctype) - req.write(tmpl('error', error=err.message or '')) - return [] + return ''.join(tmpl('error', error=err.message or '')), finally: tmpl = None