diff mercurial/hgweb/common.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 59a168019255
children 76ff3a715cf2
line wrap: on
line diff
--- a/mercurial/hgweb/common.py	Tue Jan 15 01:05:12 2013 +0100
+++ b/mercurial/hgweb/common.py	Tue Jan 15 01:07:03 2013 +0100
@@ -140,11 +140,11 @@
     try:
         os.stat(path)
         ct = mimetypes.guess_type(path)[0] or "text/plain"
-        req.respond(HTTP_OK, ct, length = os.path.getsize(path))
         fp = open(path, 'rb')
         data = fp.read()
         fp.close()
-        return data
+        req.respond(HTTP_OK, ct, body=data)
+        return ""
     except TypeError:
         raise ErrorResponse(HTTP_SERVER_ERROR, 'illegal filename')
     except OSError, err: