Takeaways
- The
307 Temporary Redirectstatus response code indicates that the resource requested has been temporarily moved to the URL given by theLocationheaders. - The method and the body of the original request are reused to perform the redirected request.
- In the cases where you want the method used to be changed to
GET, use303 See Otherinstead. This is useful when you want to give an answer to aPUTmethod that is not the uploaded resources, but a confirmation message (like "You successfully uploaded XYZ"). - The only difference between
307and302is that307guarantees that the method and the body will not be changed when the redirected request is made. - With
302, some old clients were incorrectly changing the method toGET: the behaviour with non-GETmethods and302is then unpredictable on the Web, whereas the behaviour with307is predictable. ForGETrequests, their behaviour is identical.
Information
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.
Since the redirection can change over time, the client ought to continue using the original effective request URI for future requests.
The server should generate a Location header field in the response containing a URI reference for the different URI. The user agent may use the Location field value for automatic redirection. The server's response payload usually contains a short hypertext note with a hyperlink to the different URI(s).