Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/protocol.py @ 18352:e33b9b92a200
hgweb: pass the actual response body to request.response, not just the length
This makes it less likely to send a response that doesn't match Content-Length.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Tue, 15 Jan 2013 01:07:03 +0100 |
parents | 6c2563b2c1c6 |
children | 8d477543882b |
comparison
equal
deleted
inserted
replaced
18351:3fbdbeab38cc | 18352:e33b9b92a200 |
---|---|
73 | 73 |
74 def call(repo, req, cmd): | 74 def call(repo, req, cmd): |
75 p = webproto(req, repo.ui) | 75 p = webproto(req, repo.ui) |
76 rsp = wireproto.dispatch(repo, p, cmd) | 76 rsp = wireproto.dispatch(repo, p, cmd) |
77 if isinstance(rsp, str): | 77 if isinstance(rsp, str): |
78 req.respond(HTTP_OK, HGTYPE, length=len(rsp)) | 78 req.respond(HTTP_OK, HGTYPE, body=rsp) |
79 return [rsp] | 79 return [] |
80 elif isinstance(rsp, wireproto.streamres): | 80 elif isinstance(rsp, wireproto.streamres): |
81 req.respond(HTTP_OK, HGTYPE) | 81 req.respond(HTTP_OK, HGTYPE) |
82 return rsp.gen | 82 return rsp.gen |
83 elif isinstance(rsp, wireproto.pushres): | 83 elif isinstance(rsp, wireproto.pushres): |
84 val = p.restore() | 84 val = p.restore() |
85 rsp = '%d\n%s' % (rsp.res, val) | 85 rsp = '%d\n%s' % (rsp.res, val) |
86 req.respond(HTTP_OK, HGTYPE, length=len(rsp)) | 86 req.respond(HTTP_OK, HGTYPE, body=rsp) |
87 return [rsp] | 87 return [] |
88 elif isinstance(rsp, wireproto.pusherr): | 88 elif isinstance(rsp, wireproto.pusherr): |
89 # drain the incoming bundle | 89 # drain the incoming bundle |
90 req.drain() | 90 req.drain() |
91 p.restore() | 91 p.restore() |
92 rsp = '0\n%s\n' % rsp.res | 92 rsp = '0\n%s\n' % rsp.res |
93 req.respond(HTTP_OK, HGTYPE, length=len(rsp)) | 93 req.respond(HTTP_OK, HGTYPE, body=rsp) |
94 return [rsp] | 94 return [] |
95 elif isinstance(rsp, wireproto.ooberror): | 95 elif isinstance(rsp, wireproto.ooberror): |
96 rsp = rsp.message | 96 rsp = rsp.message |
97 req.respond(HTTP_OK, HGERRTYPE, length=len(rsp)) | 97 req.respond(HTTP_OK, HGERRTYPE, body=rsp) |
98 return [rsp] | 98 return [] |