From fffb58fb075a0673e1b85eb722b0f101ea302021 Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Wed, 28 Feb 2024 21:34:19 +1300 Subject: [PATCH] set vary headers #57 --- app/activitypub/routes.py | 4 ++-- app/post/routes.py | 5 +++-- app/utils.py | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/activitypub/routes.py b/app/activitypub/routes.py index 878f7d87..92b3cc06 100644 --- a/app/activitypub/routes.py +++ b/app/activitypub/routes.py @@ -1055,7 +1055,7 @@ def comment_ap(comment_id): } resp = jsonify(reply_data) resp.content_type = 'application/activity+json' - resp.headers.set('Vary', 'Accept, Cookie') + resp.headers.set('Vary', 'Accept, Accept-Encoding, Cookie') return resp else: reply = PostReply.query.get_or_404(comment_id) @@ -1076,7 +1076,7 @@ def post_ap(post_id): post_data['@context'] = default_context() resp = jsonify(post_data) resp.content_type = 'application/activity+json' - resp.headers.set('Vary', 'Accept, Cookie') + resp.headers.set('Vary', 'Accept, Accept-Encoding, Cookie') return resp else: return show_post(post_id) diff --git a/app/post/routes.py b/app/post/routes.py index 3159af11..82ed87dc 100644 --- a/app/post/routes.py +++ b/app/post/routes.py @@ -182,7 +182,7 @@ def show_post(post_id: int): joined_communities=joined_communities(current_user.get_id()), inoculation=inoculation[randint(0, len(inoculation) - 1)] ) - response.headers.set('Vary', 'Accept, Cookie') + response.headers.set('Vary', 'Accept, Accept-Encoding, Cookie') return response @@ -374,7 +374,8 @@ def continue_discussion(post_id, comment_id): moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()), community=post.community, inoculation=inoculation[randint(0, len(inoculation) - 1)]) - return response.headers.set('Vary', 'Accept, Cookie') + response.headers.set('Vary', 'Accept, Accept-Encoding, Cookie') + return response @bp.route('/post//comment//reply', methods=['GET', 'POST']) diff --git a/app/utils.py b/app/utils.py index d721503f..508de99e 100644 --- a/app/utils.py +++ b/app/utils.py @@ -57,6 +57,7 @@ def return_304(etag, content_type=None): resp = make_response('', 304) resp.headers.add_header('ETag', request.headers['If-None-Match']) resp.headers.add_header('Cache-Control', 'no-cache, max-age=600, must-revalidate') + resp.headers.add_header('Vary', 'Accept, Accept-Encoding, Cookie') if content_type: resp.headers.set('Content-Type', content_type) return resp