mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixes #17866: Vary: Accept-Language header when language prefix used
This commit is contained in:
@@ -172,6 +172,26 @@ class URLRedirectTests(URLTestCaseBase):
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
class URLVaryAcceptLanguageTests(URLTestCaseBase):
|
||||
"""
|
||||
Tests that 'Accept-Language' is not added to the Vary header when using
|
||||
prefixed URLs.
|
||||
"""
|
||||
def test_no_prefix_response(self):
|
||||
response = self.client.get('/not-prefixed/')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.get('Vary'), 'Accept-Language')
|
||||
|
||||
def test_en_redirect(self):
|
||||
response = self.client.get('/account/register/', HTTP_ACCEPT_LANGUAGE='en')
|
||||
self.assertRedirects(response, '/en/account/register/')
|
||||
self.assertFalse(response.get('Vary'))
|
||||
|
||||
response = self.client.get(response['location'])
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertFalse(response.get('Vary'))
|
||||
|
||||
|
||||
class URLRedirectWithoutTrailingSlashTests(URLTestCaseBase):
|
||||
"""
|
||||
Tests the redirect when the requested URL doesn't end with a slash
|
||||
|
||||
@@ -48,7 +48,8 @@ from .models import Company, TestModel
|
||||
from .patterns.tests import (URLRedirectWithoutTrailingSlashTests,
|
||||
URLTranslationTests, URLDisabledTests, URLTagTests, URLTestCaseBase,
|
||||
URLRedirectWithoutTrailingSlashSettingTests, URLNamespaceTests,
|
||||
URLPrefixTests, URLResponseTests, URLRedirectTests, PathUnusedTests)
|
||||
URLPrefixTests, URLResponseTests, URLRedirectTests, PathUnusedTests,
|
||||
URLVaryAcceptLanguageTests)
|
||||
|
||||
|
||||
here = os.path.dirname(os.path.abspath(upath(__file__)))
|
||||
|
||||
Reference in New Issue
Block a user