From 523fed1d2faafa6610f27dad9bbb7d7c4e122ea5 Mon Sep 17 00:00:00 2001 From: Ben Cail Date: Fri, 27 Oct 2023 09:23:07 -0400 Subject: Fixed #32106 -- Preserved HTTP_HOST in test Client when following redirects. Co-authored-by: David Sanders --- tests/test_client/tests.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/test_client/tests.py') diff --git a/tests/test_client/tests.py b/tests/test_client/tests.py index 402f282588..15f5cbe44e 100644 --- a/tests/test_client/tests.py +++ b/tests/test_client/tests.py @@ -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. -- cgit v1.3