Error Code Atlas

308 Permanent Redirect: Form POST Measured in 7 HTTP Clients

What happens after a form submission?

Reading the observations

Read the scope, then the individual observations.

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 308, the request arrived at the new address as a POST with its body.
  • GNU Wget 1.25.0: after a 308, the request arrived at the new address as a POST with its body.
  • Python urllib.request 3.12.13: after a 308, the client did not go to the new address; it reported HTTPError 308.
  • Python Requests 2.34.2: after a 308, the request arrived at the new address as a POST with its body.
  • Python HTTPX 0.28.1: after a 308, the request arrived at the new address as a POST with its body.
  • Node.js fetch 20.20.2: after a 308, the request arrived at the new address as a POST with its body.
  • Chromium (HTML form) 149.0.7827.55: after a 308, the request arrived at the new address as a POST with its body.

Documents and comparisons

Consider these excerpts alongside the comparison totals.

“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 308 (Permanent Redirect) status code can be used instead.” — RFC 9110 §15.4.2
“Note: This status code is much younger (June 2014) than its sibling codes and thus might not be recognized everywhere.” — RFC 9110 §15.4.9
  • After a 301, of 7 measured clients: 7 arrived there as a GET without a body.
  • After a 302, 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.

Choosing a response

Consider the guidance below in light of the observations above.

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.

To close, review the observations above together with the guidance beside them.

Does a 308 redirect keep the POST body?

After a 308, of 7 measured clients: 6 arrived there as a POST with its body; 1 did not go to the new address.