mirror of https://github.com/django/django.git
Closed files in FileResponse; refs #24072
This commit is contained in:
parent
e08318b4ef
commit
a9aec1154e
|
@ -442,6 +442,8 @@ class FileResponse(StreamingHttpResponse):
|
||||||
if hasattr(value, 'read'):
|
if hasattr(value, 'read'):
|
||||||
self.file_to_stream = value
|
self.file_to_stream = value
|
||||||
filelike = value
|
filelike = value
|
||||||
|
if hasattr(filelike, 'close'):
|
||||||
|
self._closable_objects.append(filelike)
|
||||||
value = iter(lambda: filelike.read(self.block_size), b'')
|
value = iter(lambda: filelike.read(self.block_size), b'')
|
||||||
else:
|
else:
|
||||||
self.file_to_stream = None
|
self.file_to_stream = None
|
||||||
|
|
Loading…
Reference in New Issue