зеркало из https://github.com/mozilla/bedrock.git
Add 'vary: accept-language' header to locale choice reponse
This commit is contained in:
Родитель
728b119723
Коммит
5e19a2c7a4
|
@ -87,7 +87,10 @@ def locale_selection(request, available_locales=None):
|
|||
"languages": product_details.languages,
|
||||
"available_locales": sorted(set(available_locales)),
|
||||
}
|
||||
return django_render(request, "404-locale.html", context, status=200 if is_root else 404)
|
||||
response = django_render(request, "404-locale.html", context, status=200 if is_root else 404)
|
||||
# Add the Vary header to avoid improper cache
|
||||
response["Vary"] = "Accept-Language"
|
||||
return response
|
||||
|
||||
|
||||
def render(request, template, context=None, ftl_files=None, activation_files=None, **kwargs):
|
||||
|
|
|
@ -51,6 +51,8 @@ class TestRender(TestCase):
|
|||
self.assertEqual(response.status_code, 404)
|
||||
else:
|
||||
self.assertEqual(response.status_code, 200)
|
||||
if path == "/":
|
||||
self.assertEqual(response["Vary"], "Accept-Language")
|
||||
|
||||
def test_no_accept_language_header(self):
|
||||
template = "firefox/new.html"
|
||||
|
|
Загрузка…
Ссылка в новой задаче