302 Found: Form POST Measured in 7 HTTP Clients
What happens after a form submission?
After a 302, of 7 measured clients: 7 arrived there as a GET without a body.
Measured requests and scope
Read the entries alongside the measurement scope.
Measured on Linux (x86_64, kernel 7.0.0-34-generic) against a local test server, with curl 8.18.0, GNU Wget 1.25.0, Python urllib.request 3.12.13, Python Requests 2.34.2, Python HTTPX 0.28.1, Node.js fetch 20.20.2, Chromium (HTML form) 149.0.7827.55. Windows, macOS, Firefox, Safari, older versions and other settings were not measured.
- curl 8.18.0: after a 302, the request arrived at the new address as a GET without its body.
- GNU Wget 1.25.0: after a 302, the request arrived at the new address as a GET without its body.
- Python urllib.request 3.12.13: after a 302, the request arrived at the new address as a GET without its body.
- Python Requests 2.34.2: after a 302, the request arrived at the new address as a GET without its body.
- Python HTTPX 0.28.1: after a 302, the request arrived at the new address as a GET without its body.
- Node.js fetch 20.20.2: after a 302, the request arrived at the new address as a GET without its body.
- Chromium (HTML form) 149.0.7827.55: after a 302, the request arrived at the new address as a GET without its body.
Document wording and comparison
Consider the document excerpts alongside the comparison results.
“The 307 (Temporary Redirect) status code indicates that the target resource resides temporarily under a different URI and the user agent MUST NOT change the request method if it performs an automatic redirection to that URI.” — RFC 9110 §15.4.8
“It is primarily used to allow the output of a POST action to redirect the user agent to a different resource, since doing so provides the information corresponding to the POST response as a resource that can be separately identified, bookmarked, and cached.” — RFC 9110 §15.4.4
- After a 301, of 7 measured clients: 7 arrived there as a GET without a body.
- After a 303, of 7 measured clients: 7 arrived there as a GET without a body.
- After a 307, of 7 measured clients: 6 arrived there as a POST with its body; 1 did not go to the new address.
- After a 308, of 7 measured clients: 6 arrived there as a POST with its body; 1 did not go to the new address.
Choosing a response for your form
What does your form flow need from the redirect you send back?
If the form data has to reach the new address, answer with 307 or 308: in this measurement, whenever a client went on to the new address after a 307 or 308, a POST with its body arrived there; after a 301, 302 or 303, a GET without a body arrived.
If your code posts with Python's urllib.request, handle 307 and 308 yourself: in this measurement it raised an error instead of going to the new address.
The question below closes out this page.
Read the entries above alongside the scope note, weigh the guidance against what your own flow asks for, and verify the redirect path your setup emits before you lean on it.
Does a 302 redirect change POST to GET?
“Note: For historical reasons, a user agent MAY change the request method from POST to GET for the subsequent request. If this behavior is undesired, the 307 (Temporary Redirect) status code can be used instead.” — RFC 9110 §15.4.3