Closed files in FileResponse; refs #24072

This commit is contained in:
Collin Anderson 2015-01-05 12:06:59 -05:00 committed by Tim Graham
parent e08318b4ef
commit a9aec1154e
1 changed files with 2 additions and 0 deletions

View File

@ -442,6 +442,8 @@ class FileResponse(StreamingHttpResponse):
if hasattr(value, 'read'):
self.file_to_stream = value
filelike = value
if hasattr(filelike, 'close'):
self._closable_objects.append(filelike)
value = iter(lambda: filelike.read(self.block_size), b'')
else:
self.file_to_stream = None