Mercurial > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
18351:3fbdbeab38cc | 18352:e33b9b92a200 |
---|---|
138 if os.path.exists(path): | 138 if os.path.exists(path): |
139 break | 139 break |
140 try: | 140 try: |
141 os.stat(path) | 141 os.stat(path) |
142 ct = mimetypes.guess_type(path)[0] or "text/plain" | 142 ct = mimetypes.guess_type(path)[0] or "text/plain" |
143 req.respond(HTTP_OK, ct, length = os.path.getsize(path)) | |
144 fp = open(path, 'rb') | 143 fp = open(path, 'rb') |
145 data = fp.read() | 144 data = fp.read() |
146 fp.close() | 145 fp.close() |
147 return data | 146 req.respond(HTTP_OK, ct, body=data) |
147 return "" | |
148 except TypeError: | 148 except TypeError: |
149 raise ErrorResponse(HTTP_SERVER_ERROR, 'illegal filename') | 149 raise ErrorResponse(HTTP_SERVER_ERROR, 'illegal filename') |
150 except OSError, err: | 150 except OSError, err: |
151 if err.errno == errno.ENOENT: | 151 if err.errno == errno.ENOENT: |
152 raise ErrorResponse(HTTP_NOT_FOUND) | 152 raise ErrorResponse(HTTP_NOT_FOUND) |