Fixed #31240 -- Properly closed FileResponse when wsgi.file_wrapper is used.

Thanks to Oskar Persson for the report.
This commit is contained in:
Florian Apolloner 2020-02-07 12:55:59 +01:00 committed by Mariusz Felisiak
parent 549445519c
commit 41a3b3d186
7 changed files with 63 additions and 6 deletions

View file

@ -0,0 +1,15 @@
from io import BytesIO
from django.http import FileResponse
FILE_RESPONSE_HOLDER = {}
def file_response(request):
f1 = BytesIO(b"test1")
f2 = BytesIO(b"test2")
response = FileResponse(f1)
response._resource_closers.append(f2.close)
FILE_RESPONSE_HOLDER['response'] = response
FILE_RESPONSE_HOLDER['buffers'] = (f1, f2)
return response