mirror of
https://git.linux-kernel.at/oliver/ivatar.git
synced 2025-11-17 13:38:03 +00:00
We need to ensure the Vary setting isn't set of image responses
This commit is contained in:
@@ -118,13 +118,16 @@ class AvatarImageView(TemplateView):
|
||||
if centry := caches["filesystem"].get(uri):
|
||||
# For DEBUG purpose only
|
||||
# print('Cached entry for %s' % uri)
|
||||
return HttpResponse(
|
||||
response = HttpResponse(
|
||||
centry["content"],
|
||||
content_type=centry["content_type"],
|
||||
status=centry["status"],
|
||||
reason=centry["reason"],
|
||||
charset=centry["charset"],
|
||||
)
|
||||
# Remove Vary header for images since language doesn't matter
|
||||
response["Vary"] = ""
|
||||
return response
|
||||
|
||||
# In case no digest at all is provided, return to home page
|
||||
if "digest" not in kwargs:
|
||||
@@ -294,6 +297,8 @@ class AvatarImageView(TemplateView):
|
||||
imgformat = "jpeg"
|
||||
response = CachingHttpResponse(uri, data, content_type=f"image/{imgformat}")
|
||||
response["Cache-Control"] = "max-age=%i" % CACHE_IMAGES_MAX_AGE
|
||||
# Remove Vary header for images since language doesn't matter
|
||||
response["Vary"] = ""
|
||||
return response
|
||||
|
||||
def _redirect_static_w_size(self, arg0, size):
|
||||
@@ -312,6 +317,8 @@ class AvatarImageView(TemplateView):
|
||||
data.seek(0)
|
||||
response = CachingHttpResponse(uri, data, content_type="image/png")
|
||||
response["Cache-Control"] = "max-age=%i" % CACHE_IMAGES_MAX_AGE
|
||||
# Remove Vary header for images since language doesn't matter
|
||||
response["Vary"] = ""
|
||||
return response
|
||||
|
||||
def _return_cached_png(self, arg0, data, uri):
|
||||
@@ -407,6 +414,8 @@ class GravatarProxyView(View):
|
||||
data.read(), content_type=f"image/{file_format(img.format)}"
|
||||
)
|
||||
response["Cache-Control"] = "max-age=%i" % CACHE_IMAGES_MAX_AGE
|
||||
# Remove Vary header for images since language doesn't matter
|
||||
response["Vary"] = ""
|
||||
return response
|
||||
|
||||
except ValueError as exc:
|
||||
@@ -526,6 +535,8 @@ class BlueskyProxyView(View):
|
||||
data.read(), content_type=f"image/{file_format(format)}"
|
||||
)
|
||||
response["Cache-Control"] = "max-age=%i" % CACHE_IMAGES_MAX_AGE
|
||||
# Remove Vary header for images since language doesn't matter
|
||||
response["Vary"] = ""
|
||||
return response
|
||||
except ValueError as exc:
|
||||
print(f"Value error: {exc}")
|
||||
|
||||
Reference in New Issue
Block a user