summaryrefslogtreecommitdiff
path: root/tests/i18n
diff options
context:
space:
mode:
authorAlex Hayward <alex.hayward@telespazio.com>2021-05-19 12:19:23 +0100
committerCarlton Gibson <carlton@noumenal.es>2021-09-01 14:02:37 +0200
commiteeed488a3439c5c5c3f0b5991ee400851057e127 (patch)
tree4804090d847a3a5152ff6bcbe26089d22b6ecfcb /tests/i18n
parent84c7c4a477eae5de394d036d7ba1e58a37e18b69 (diff)
downloaddjango-eeed488a3439c5c5c3f0b5991ee400851057e127.tar.gz
Fixed #32768 -- Added Vary header when redirecting to prefixed i18n pattern.
get_language_from_request() uses Accept-Language and/or Cookie to determine the correct redirect. Upstream caches need the matching Vary header to cache the result.
Diffstat (limited to 'tests/i18n')
-rw-r--r--tests/i18n/patterns/tests.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/tests/i18n/patterns/tests.py b/tests/i18n/patterns/tests.py
index 96e9453e9e..ebd2430428 100644
--- a/tests/i18n/patterns/tests.py
+++ b/tests/i18n/patterns/tests.py
@@ -254,9 +254,13 @@ class URLVaryAcceptLanguageTests(URLTestCaseBase):
self.assertEqual(response.get('Vary'), 'Accept-Language')
def test_en_redirect(self):
+ """
+ The redirect to a prefixed URL depends on 'Accept-Language' and
+ 'Cookie', but once prefixed no header is set.
+ """
response = self.client.get('/account/register/', HTTP_ACCEPT_LANGUAGE='en')
self.assertRedirects(response, '/en/account/register/')
- self.assertFalse(response.get('Vary'))
+ self.assertEqual(response.get('Vary'), 'Accept-Language, Cookie')
response = self.client.get(response.headers['location'])
self.assertEqual(response.status_code, 200)