Mercurial > public > mercurial-scm > hg-stable
diff mercurial/hgweb/request.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 | 3fbdbeab38cc |
children | 328739ea70c3 |
line wrap: on
line diff
--- a/mercurial/hgweb/request.py Tue Jan 15 01:05:12 2013 +0100 +++ b/mercurial/hgweb/request.py Tue Jan 15 01:07:03 2013 +0100 @@ -70,7 +70,7 @@ for s in util.filechunkiter(self.inp, limit=length): pass - def respond(self, status, type, filename=None, length=None): + def respond(self, status, type, filename=None, body=None): if self._start_response is not None: self.headers.append(('Content-Type', type)) if filename: @@ -78,8 +78,8 @@ .replace('\\', '\\\\').replace('"', '\\"')) self.headers.append(('Content-Disposition', 'inline; filename="%s"' % filename)) - if length is not None: - self.headers.append(('Content-Length', str(length))) + if body is not None: + self.headers.append(('Content-Length', str(len(body)))) for k, v in self.headers: if not isinstance(v, str): @@ -103,6 +103,9 @@ self.server_write = self._start_response(status, self.headers) self._start_response = None self.headers = [] + if body is not None: + self.write(body) + self.server_write = None def write(self, thing): if thing: