Ticket #7894: file_wrapper_response.diff
File file_wrapper_response.diff, 2.0 KB (added by , 16 years ago) |
---|
-
django/http/__init__.py
424 424 def __init__(self, *args, **kwargs): 425 425 HttpResponse.__init__(self, *args, **kwargs) 426 426 427 class HttpResponseFileWrapper(HttpResponse): 428 def __init__(self, filelike, block_size=8192, **kwargs): 429 default_reader = iter(lambda: filelike.read(block_size), '') 430 HttpResponse.__init__(self, content=default_reader, **kwargs) 431 self.filelike = filelike 432 self.block_size = block_size 433 427 434 # A backwards compatible alias for HttpRequest.get_host. 428 435 def get_host(request): 429 436 return request.get_host() -
django/core/servers/basehttp.py
312 312 in the event loop to iterate over the data, and to call 313 313 'self.close()' once the response is finished. 314 314 """ 315 if not self.result_is_file() andnot self.sendfile():315 if not self.result_is_file() or not self.sendfile(): 316 316 for data in self.result: 317 317 self.write(data) 318 318 self.finish_content() -
django/core/handlers/wsgi.py
232 232 for c in response.cookies.values(): 233 233 response_headers.append(('Set-Cookie', str(c.output(header='')))) 234 234 start_response(status, response_headers) 235 return response 235 if (isinstance(response, http.HttpResponseFileWrapper) and 236 'wsgi.file_wrapper'in environ): 237 return environ['wsgi.file_wrapper'](response.filelike, response.block_size) 238 else: 239 return response 236 240