plain 0.2.3__py3-none-any.whl → 0.2.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- plain/assets/views.py +13 -5
- {plain-0.2.3.dist-info → plain-0.2.5.dist-info}/METADATA +1 -1
- {plain-0.2.3.dist-info → plain-0.2.5.dist-info}/RECORD +6 -6
- {plain-0.2.3.dist-info → plain-0.2.5.dist-info}/LICENSE +0 -0
- {plain-0.2.3.dist-info → plain-0.2.5.dist-info}/WHEEL +0 -0
- {plain-0.2.3.dist-info → plain-0.2.5.dist-info}/entry_points.txt +0 -0
plain/assets/views.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import functools
|
2
|
+
import mimetypes
|
2
3
|
import os
|
3
4
|
from email.utils import formatdate, parsedate
|
4
5
|
from io import BytesIO
|
@@ -53,9 +54,12 @@ class AssetView(View):
|
|
53
54
|
if not_modified_response := self.get_conditional_response(absolute_path):
|
54
55
|
return not_modified_response
|
55
56
|
|
57
|
+
content_type, _ = mimetypes.guess_type(absolute_path)
|
58
|
+
|
56
59
|
response = FileResponse(
|
57
60
|
open(absolute_path, "rb"),
|
58
|
-
filename=os.path.basename(absolute_path),
|
61
|
+
filename=os.path.basename(absolute_path),
|
62
|
+
content_type=content_type,
|
59
63
|
)
|
60
64
|
response.headers = self.update_headers(response.headers, absolute_path)
|
61
65
|
return response
|
@@ -124,10 +128,8 @@ class AssetView(View):
|
|
124
128
|
headers["Vary"] = vary + ", Accept-Encoding"
|
125
129
|
|
126
130
|
# If the file is compressed, tell the browser
|
127
|
-
if
|
128
|
-
headers.setdefault("Content-Encoding",
|
129
|
-
elif path.endswith(".br"):
|
130
|
-
headers.setdefault("Content-Encoding", "br")
|
131
|
+
if encoding := mimetypes.guess_type(path)[1]:
|
132
|
+
headers.setdefault("Content-Encoding", encoding)
|
131
133
|
|
132
134
|
is_immutable = self.is_immutable(path)
|
133
135
|
|
@@ -147,6 +149,12 @@ class AssetView(View):
|
|
147
149
|
if etag := self.get_etag(path):
|
148
150
|
headers.setdefault("ETag", etag)
|
149
151
|
|
152
|
+
if "Content-Disposition" in headers:
|
153
|
+
# This header messes up Safari...
|
154
|
+
# https://github.com/evansd/whitenoise/commit/93657cf88e14b919cb726864814617a6a639e507
|
155
|
+
# At some point, should probably look at not using FileResponse at all?
|
156
|
+
del headers["Content-Disposition"]
|
157
|
+
|
150
158
|
return headers
|
151
159
|
|
152
160
|
def is_immutable(self, path):
|
@@ -6,7 +6,7 @@ plain/assets/compile.py,sha256=lsnciN85YjHe6d8VIKJi1L8r7NGHNzMOe9L87wObM5I,3287
|
|
6
6
|
plain/assets/finders.py,sha256=WEKAnXTmpuQ7UKLZz7vHPrKFdDOkuZSP6_JTKmIxrKg,1268
|
7
7
|
plain/assets/fingerprints.py,sha256=1NKAnnXVlncY5iimXztr0NL3RIjBKsNlZRIe6nmItJc,931
|
8
8
|
plain/assets/urls.py,sha256=ZTIoM1Zq35JaXZ3wFhXhfGa7VoITDNlH9i5RS0R5xow,933
|
9
|
-
plain/assets/views.py,sha256=
|
9
|
+
plain/assets/views.py,sha256=dhjIpMu0GDR_VGbXM90_6RnC84C2C4bFv1RxDVklGBk,9173
|
10
10
|
plain/cli/README.md,sha256=bEp9B9C92YEa44wN2IywTmNZsYBv_uGq9AS_bBiAGdY,2580
|
11
11
|
plain/cli/__init__.py,sha256=9ByBOIdM8DebChjNz-RH2atdz4vWe8somlwNEsbhwh4,40
|
12
12
|
plain/cli/cli.py,sha256=JyPNQGlczqCyLxZq5Jh_591rKpBMN91JHGXdaTuPWJ0,14841
|
@@ -152,8 +152,8 @@ plain/views/objects.py,sha256=9QBYyb8PgkRirXCQ8-Pms4_yMzP37dfeL30hWRYmtZg,7909
|
|
152
152
|
plain/views/redirect.py,sha256=KLnlktzK6ZNMTlaEiZpMKQMEP5zeTgGLJ9BIkIJfwBo,1733
|
153
153
|
plain/views/templates.py,sha256=nF9CcdhhjAyp3LB0RrSYnBaHpHzMfPSw719RCdcXk7o,2007
|
154
154
|
plain/wsgi.py,sha256=R6k5FiAElvGDApEbMPTT0MPqSD7n2e2Az5chQqJZU0I,236
|
155
|
-
plain-0.2.
|
156
|
-
plain-0.2.
|
157
|
-
plain-0.2.
|
158
|
-
plain-0.2.
|
159
|
-
plain-0.2.
|
155
|
+
plain-0.2.5.dist-info/LICENSE,sha256=m0D5O7QoH9l5Vz_rrX_9r-C8d9UNr_ciK6Qwac7o6yo,3175
|
156
|
+
plain-0.2.5.dist-info/METADATA,sha256=KyaK66wyLHe9OHXObllwbTbUPmyk6jNqTGRo-yOJkkI,2716
|
157
|
+
plain-0.2.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
158
|
+
plain-0.2.5.dist-info/entry_points.txt,sha256=7O1RZTmMasKYB73bfqQcTwIhsXo7RjEIKv2WbtTtOIM,39
|
159
|
+
plain-0.2.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|