Fixed #30567 -- Made WSGIHandler pass FileResponse.block_size to wsgi.file_wrapper.
This commit is contained in:
parent
806ba19bbf
commit
4b4e68a7a6
|
@ -141,7 +141,7 @@ class WSGIHandler(base.BaseHandler):
|
||||||
]
|
]
|
||||||
start_response(status, response_headers)
|
start_response(status, response_headers)
|
||||||
if getattr(response, 'file_to_stream', None) is not None and environ.get('wsgi.file_wrapper'):
|
if getattr(response, 'file_to_stream', None) is not None and environ.get('wsgi.file_wrapper'):
|
||||||
response = environ['wsgi.file_wrapper'](response.file_to_stream)
|
response = environ['wsgi.file_wrapper'](response.file_to_stream, response.block_size)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ from django.core.servers.basehttp import get_internal_wsgi_application
|
||||||
from django.core.signals import request_started
|
from django.core.signals import request_started
|
||||||
from django.core.wsgi import get_wsgi_application
|
from django.core.wsgi import get_wsgi_application
|
||||||
from django.db import close_old_connections
|
from django.db import close_old_connections
|
||||||
|
from django.http import FileResponse
|
||||||
from django.test import SimpleTestCase, override_settings
|
from django.test import SimpleTestCase, override_settings
|
||||||
from django.test.client import RequestFactory
|
from django.test.client import RequestFactory
|
||||||
|
|
||||||
|
@ -51,7 +52,8 @@ class WSGITest(SimpleTestCase):
|
||||||
FileResponse uses wsgi.file_wrapper.
|
FileResponse uses wsgi.file_wrapper.
|
||||||
"""
|
"""
|
||||||
class FileWrapper:
|
class FileWrapper:
|
||||||
def __init__(self, filelike, blksize=8192):
|
def __init__(self, filelike, block_size=None):
|
||||||
|
self.block_size = block_size
|
||||||
filelike.close()
|
filelike.close()
|
||||||
application = get_wsgi_application()
|
application = get_wsgi_application()
|
||||||
environ = self.request_factory._base_environ(
|
environ = self.request_factory._base_environ(
|
||||||
|
@ -67,6 +69,7 @@ class WSGITest(SimpleTestCase):
|
||||||
response = application(environ, start_response)
|
response = application(environ, start_response)
|
||||||
self.assertEqual(response_data['status'], '200 OK')
|
self.assertEqual(response_data['status'], '200 OK')
|
||||||
self.assertIsInstance(response, FileWrapper)
|
self.assertIsInstance(response, FileWrapper)
|
||||||
|
self.assertEqual(response.block_size, FileResponse.block_size)
|
||||||
|
|
||||||
|
|
||||||
class GetInternalWSGIApplicationTest(SimpleTestCase):
|
class GetInternalWSGIApplicationTest(SimpleTestCase):
|
||||||
|
|
Loading…
Reference in New Issue