1
0
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:
Łukasz Langa
2013-02-23 19:41:33 +01:00
parent e3296268de
commit 539900f117
5 changed files with 42 additions and 13 deletions

View File

@@ -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

View File

@@ -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__)))