Skip to content

Commit f418c01

Browse files
authored
Fixed 303 redirect for PUT method (#27)
1 parent 4f596eb commit f418c01

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

inertia/middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def __call__(self, request):
2626
return response
2727

2828
def is_non_post_redirect(self, request, response):
29-
return self.is_redirect_request(response) and request.method in ['POST', 'PATCH', 'DELETE']
29+
return self.is_redirect_request(response) and request.method in ['PUT', 'PATCH', 'DELETE']
3030

3131
def is_inertia_request(self, request):
3232
return 'X-Inertia' in request.headers

inertia/tests/test_middleware.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ def test_stale_versions_are_refreshed(self):
1616
self.assertEqual(response.headers['X-Inertia-Location'], 'http://testserver/empty/')
1717

1818
def test_redirect_status(self):
19-
for http_method in ['post', 'patch', 'delete']:
19+
response = self.inertia.post('/redirect/')
20+
self.assertEqual(response.status_code, 302)
21+
22+
for http_method in ['put', 'patch', 'delete']:
2023
response = getattr(self.inertia, http_method)('/redirect/')
2124

2225
self.assertEqual(response.status_code, 303)
2326

24-
2527
def test_a_request_not_from_inertia_is_ignored(self):
2628
response = self.client.get('/empty/',
2729
HTTP_X_INERTIA_VERSION='some-nonsense',

0 commit comments

Comments
 (0)