1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #32106 -- Preserved HTTP_HOST in test Client when following redirects.

Co-authored-by: David Sanders <shang.xiao.sanders@gmail.com>
This commit is contained in:
Ben Cail
2023-10-27 09:23:07 -04:00
committed by Mariusz Felisiak
parent 9b18af4f6f
commit 523fed1d2f
4 changed files with 22 additions and 0 deletions

View File

@@ -856,6 +856,13 @@ class ClientTest(TestCase):
response, "https://www.djangoproject.com/", fetch_redirect_response=False
)
@override_settings(ALLOWED_HOSTS=["hostname1", "hostname2"])
def test_redirect_with_http_host(self):
response = self.client.get(
"/redirect_to_different_hostname/", follow=True, HTTP_HOST="hostname1"
)
self.assertEqual(response.content, b"hostname2")
def test_external_redirect_without_trailing_slash(self):
"""
Client._handle_redirects() with an empty path.