From a9aec1154e5b65fcaf608801905a1bbafcfbfbf7 Mon Sep 17 00:00:00 2001 From: Collin Anderson Date: Mon, 5 Jan 2015 12:06:59 -0500 Subject: [PATCH] Closed files in FileResponse; refs #24072 --- django/http/response.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/django/http/response.py b/django/http/response.py index 5168834b231..560e2ac7a57 100644 --- a/django/http/response.py +++ b/django/http/response.py @@ -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