How does HTTP redirect work with HTTP methods?

52 Views Asked by At

I read the HTTP response status code, location and MDN documentation, what I could understand was that:

Permanent:

  • 301: Permanent redirect
    • Accepted request method: All HTTP methods
    • Recommended request method: GET HEAD
    • Redirect method: Must be changed to GET
  • 308: Permanent redirect
    • Accepted request method: All HTTP methods
    • Recommended application method: Any
    • Redirect method: Preserve the request method

Temporary

  • 302: Temporary redirect
    • Accepted request method: All HTTP methods
    • Recommended request method: GET HEAD
    • Redirect method: Must be changed to GET
  • 307: Temporary redirect
    • Accepted request method: All HTTP methods
    • Recommended application method: Any
    • Redirect method: Preserve the request method
  • 303: See other
    • Accepted request method: All HTTP methods
    • Recommended request method:POST PUT
    • Request redirection method: Must be changed to GET

This behavior is due to this and this, I quote:

...Prevailing practice eventually converged on changing the method to GET...

  1. Change the request method according to the redirecting status code's semantics, if applicable.

First question: Is this correct?

But what does point 5 mean?

If the request method has been changed to GET or HEAD, remove...

I now know that HTTP status codes 301, 302 and 303 redirect is changed to the GET method, but...

Second question in which case is it changed to a HEAD method (For exmaple, from POST to HEAD, PUT to HEAD, etc.)?

Third question: Is there a way that the client (may be a browser or other user agent) can redirect from a GET to POST, or a DELETE to GET, etc.? I ask this to see what the limit of this is or simply, is this incoherent to do?

0

There are 0 best solutions below