mirror of
https://github.com/django/django.git
synced 2025-01-03 15:06:09 +00:00
Fixed #34405 -- Fixed setting Content-Type header in FileResponse for compress and brotli.
Thanks Chamal De Silva for the report.
This commit is contained in:
parent
fbe850106b
commit
254ad2e345
@ -609,7 +609,9 @@ class FileResponse(StreamingHttpResponse):
|
|||||||
# Encoding isn't set to prevent browsers from automatically
|
# Encoding isn't set to prevent browsers from automatically
|
||||||
# uncompressing files.
|
# uncompressing files.
|
||||||
content_type = {
|
content_type = {
|
||||||
|
"br": "application/x-brotli",
|
||||||
"bzip2": "application/x-bzip",
|
"bzip2": "application/x-bzip",
|
||||||
|
"compress": "application/x-compress",
|
||||||
"gzip": "application/gzip",
|
"gzip": "application/gzip",
|
||||||
"xz": "application/x-xz",
|
"xz": "application/x-xz",
|
||||||
}.get(encoding, content_type)
|
}.get(encoding, content_type)
|
||||||
|
@ -253,8 +253,10 @@ class FileResponseTests(SimpleTestCase):
|
|||||||
"""
|
"""
|
||||||
test_tuples = (
|
test_tuples = (
|
||||||
(".tar.gz", "application/gzip"),
|
(".tar.gz", "application/gzip"),
|
||||||
|
(".tar.br", "application/x-brotli"),
|
||||||
(".tar.bz2", "application/x-bzip"),
|
(".tar.bz2", "application/x-bzip"),
|
||||||
(".tar.xz", "application/x-xz"),
|
(".tar.xz", "application/x-xz"),
|
||||||
|
(".tar.Z", "application/x-compress"),
|
||||||
)
|
)
|
||||||
for extension, mimetype in test_tuples:
|
for extension, mimetype in test_tuples:
|
||||||
with self.subTest(ext=extension):
|
with self.subTest(ext=extension):
|
||||||
|
Loading…
Reference in New Issue
Block a user