mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #31494 -- Preserved query strings when following HTTP 307/308 redirects in test client.
This commit is contained in:
committed by
Mariusz Felisiak
parent
6425fd3124
commit
7c947f0f5a
@@ -284,6 +284,20 @@ class ClientTest(TestCase):
|
||||
self.assertEqual(response.request['PATH_INFO'], '/post_view/')
|
||||
self.assertEqual(response.request['REQUEST_METHOD'], method.upper())
|
||||
|
||||
def test_follow_307_and_308_preserves_query_string(self):
|
||||
methods = ('post', 'options', 'put', 'patch', 'delete', 'trace')
|
||||
codes = (307, 308)
|
||||
for method, code in itertools.product(methods, codes):
|
||||
with self.subTest(method=method, code=code):
|
||||
req_method = getattr(self.client, method)
|
||||
response = req_method(
|
||||
'/redirect_view_%s_query_string/' % code,
|
||||
data={'value': 'test'},
|
||||
follow=True,
|
||||
)
|
||||
self.assertRedirects(response, '/post_view/?hello=world', status_code=code)
|
||||
self.assertEqual(response.request['QUERY_STRING'], 'hello=world')
|
||||
|
||||
def test_follow_307_and_308_get_head_query_string(self):
|
||||
methods = ('get', 'head')
|
||||
codes = (307, 308)
|
||||
|
||||
Reference in New Issue
Block a user