Skip to content

Commit b74b810

Browse files
committed
Use mimetypes to get the asset encoding header
1 parent d867386 commit b74b810

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

plain/plain/assets/views.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,8 @@ def update_headers(self, headers, path):
128128
headers["Vary"] = vary + ", Accept-Encoding"
129129

130130
# If the file is compressed, tell the browser
131-
if path.endswith(".gz"):
132-
headers.setdefault("Content-Encoding", "gzip")
133-
elif path.endswith(".br"):
134-
headers.setdefault("Content-Encoding", "br")
131+
if encoding := mimetypes.guess_type(path)[1]:
132+
headers.setdefault("Content-Encoding", encoding)
135133

136134
is_immutable = self.is_immutable(path)
137135

0 commit comments

Comments
 (0)