Mercurial > hg
comparison mercurial/hgweb/hgweb_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 | 57b954d8d003 |
children | a42d27bc809d |
comparison
equal
deleted
inserted
replaced
6944:7e5f3480c45b | 6945:2cfdabe235fb |
---|---|
172 content = webcommands.rawfile(self, req, tmpl) | 172 content = webcommands.rawfile(self, req, tmpl) |
173 else: | 173 else: |
174 content = getattr(webcommands, cmd)(self, req, tmpl) | 174 content = getattr(webcommands, cmd)(self, req, tmpl) |
175 req.respond(HTTP_OK, ctype) | 175 req.respond(HTTP_OK, ctype) |
176 | 176 |
177 req.write(content) | 177 return ''.join(content), |
178 return [] | |
179 | 178 |
180 except revlog.LookupError, err: | 179 except revlog.LookupError, err: |
181 req.respond(HTTP_NOT_FOUND, ctype) | 180 req.respond(HTTP_NOT_FOUND, ctype) |
182 msg = str(err) | 181 msg = str(err) |
183 if 'manifest' not in msg: | 182 if 'manifest' not in msg: |
184 msg = 'revision not found: %s' % err.name | 183 msg = 'revision not found: %s' % err.name |
185 req.write(tmpl('error', error=msg)) | 184 return ''.join(tmpl('error', error=msg)), |
186 return [] | |
187 except (RepoError, revlog.RevlogError), inst: | 185 except (RepoError, revlog.RevlogError), inst: |
188 req.respond(HTTP_SERVER_ERROR, ctype) | 186 req.respond(HTTP_SERVER_ERROR, ctype) |
189 req.write(tmpl('error', error=str(inst))) | 187 return ''.join(tmpl('error', error=str(inst))), |
190 return [] | |
191 except ErrorResponse, inst: | 188 except ErrorResponse, inst: |
192 req.respond(inst.code, ctype) | 189 req.respond(inst.code, ctype) |
193 req.write(tmpl('error', error=inst.message)) | 190 return ''.join(tmpl('error', error=inst.message)), |
194 return [] | |
195 | 191 |
196 def templater(self, req): | 192 def templater(self, req): |
197 | 193 |
198 # determine scheme, port and server name | 194 # determine scheme, port and server name |
199 # this is needed to create absolute urls | 195 # this is needed to create absolute urls |