Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/hgwebdir_mod.py @ 7396:526c40a74bd0
templater: return data in increasing chunk sizes
Currently hgweb is not streaming its output -- it accumulates the
entire response before sending it. This patch restores streaming
behaviour. To avoid having to synchronously write many tiny fragments,
this patch also adds buffering to the template generator. Local
testing of a fetch of a 100,000 line file with wget produces a slight
slowdown overall (up from 6.5 seconds to 7.2 seconds), but instead of
waiting 6 seconds for headers to arrive, output begins immediately.
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Fri, 21 Nov 2008 15:51:40 -0800 |
parents | feb0b76b6717 |
children | 79d1bb737c16 |
comparison
equal
deleted
inserted
replaced
7395:e2048f5c7bf5 | 7396:526c40a74bd0 |
---|---|
114 return staticfile(static, fname, req) | 114 return staticfile(static, fname, req) |
115 | 115 |
116 # top-level index | 116 # top-level index |
117 elif not virtual: | 117 elif not virtual: |
118 req.respond(HTTP_OK, ctype) | 118 req.respond(HTTP_OK, ctype) |
119 return ''.join(self.makeindex(req, tmpl)), | 119 return self.makeindex(req, tmpl) |
120 | 120 |
121 # nested indexes and hgwebs | 121 # nested indexes and hgwebs |
122 | 122 |
123 repos = dict(self.repos) | 123 repos = dict(self.repos) |
124 while virtual: | 124 while virtual: |
136 | 136 |
137 # browse subdirectories | 137 # browse subdirectories |
138 subdir = virtual + '/' | 138 subdir = virtual + '/' |
139 if [r for r in repos if r.startswith(subdir)]: | 139 if [r for r in repos if r.startswith(subdir)]: |
140 req.respond(HTTP_OK, ctype) | 140 req.respond(HTTP_OK, ctype) |
141 return ''.join(self.makeindex(req, tmpl, subdir)), | 141 return self.makeindex(req, tmpl, subdir) |
142 | 142 |
143 up = virtual.rfind('/') | 143 up = virtual.rfind('/') |
144 if up < 0: | 144 if up < 0: |
145 break | 145 break |
146 virtual = virtual[:up] | 146 virtual = virtual[:up] |
147 | 147 |
148 # prefixes not found | 148 # prefixes not found |
149 req.respond(HTTP_NOT_FOUND, ctype) | 149 req.respond(HTTP_NOT_FOUND, ctype) |
150 return ''.join(tmpl("notfound", repo=virtual)), | 150 return tmpl("notfound", repo=virtual) |
151 | 151 |
152 except ErrorResponse, err: | 152 except ErrorResponse, err: |
153 req.respond(err.code, ctype) | 153 req.respond(err.code, ctype) |
154 return ''.join(tmpl('error', error=err.message or '')), | 154 return tmpl('error', error=err.message or '') |
155 finally: | 155 finally: |
156 tmpl = None | 156 tmpl = None |
157 | 157 |
158 def makeindex(self, req, tmpl, subdir=""): | 158 def makeindex(self, req, tmpl, subdir=""): |
159 | 159 |