Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/hgweb_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 | 1a5c9ca2bfd5 |
children | b663b5563de7 |
comparison
equal
deleted
inserted
replaced
7395:e2048f5c7bf5 | 7396:526c40a74bd0 |
---|---|
180 content = webcommands.rawfile(self, req, tmpl) | 180 content = webcommands.rawfile(self, req, tmpl) |
181 else: | 181 else: |
182 content = getattr(webcommands, cmd)(self, req, tmpl) | 182 content = getattr(webcommands, cmd)(self, req, tmpl) |
183 req.respond(HTTP_OK, ctype) | 183 req.respond(HTTP_OK, ctype) |
184 | 184 |
185 return ''.join(content), | 185 return content |
186 | 186 |
187 except revlog.LookupError, err: | 187 except revlog.LookupError, err: |
188 req.respond(HTTP_NOT_FOUND, ctype) | 188 req.respond(HTTP_NOT_FOUND, ctype) |
189 msg = str(err) | 189 msg = str(err) |
190 if 'manifest' not in msg: | 190 if 'manifest' not in msg: |
191 msg = 'revision not found: %s' % err.name | 191 msg = 'revision not found: %s' % err.name |
192 return ''.join(tmpl('error', error=msg)), | 192 return tmpl('error', error=msg) |
193 except (RepoError, revlog.RevlogError), inst: | 193 except (RepoError, revlog.RevlogError), inst: |
194 req.respond(HTTP_SERVER_ERROR, ctype) | 194 req.respond(HTTP_SERVER_ERROR, ctype) |
195 return ''.join(tmpl('error', error=str(inst))), | 195 return tmpl('error', error=str(inst)) |
196 except ErrorResponse, inst: | 196 except ErrorResponse, inst: |
197 req.respond(inst.code, ctype) | 197 req.respond(inst.code, ctype) |
198 return ''.join(tmpl('error', error=inst.message)), | 198 return tmpl('error', error=inst.message) |
199 | 199 |
200 def templater(self, req): | 200 def templater(self, req): |
201 | 201 |
202 # determine scheme, port and server name | 202 # determine scheme, port and server name |
203 # this is needed to create absolute urls | 203 # this is needed to create absolute urls |