M
M
msimrial2017-03-23 12:40:11
PHP
msimrial, 2017-03-23 12:40:11

Why is there no redirect on post request?

If there is an article about why you can implement a redirect with a get request, but not with a post, please post it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Axian Ltd., 2017-03-23
@msimrial

--cut------------------
The simplest situations on the WWW are "idempotent" transactions, ie those which can be repeated without causing any harm. These are typically "GET" transactions, either because they are retrieval of straightforward URL references (eg href= or src= attributes in HTML), or because they are form submissions using the GET method. Redirecting a transaction of that kind is straightforward, and no questions asked: the client receives the redirection response, including a Location: header that specifies the new URL, and the client reacts to it by re-issuing the transaction to the new URL. There's a difference between the different 30x status codes associated with these redirections in their implied cacheability, but otherwise they are basically similar (301 and 302) in response to GET requests.
POST transactions are different, since they are defined to be, in principle, non-idempotent (such as ordering a pizza, casting a vote or whatever) and mustn't be arbitrarily repeated.
The HTTP protocol specifications are designed to take this distinction into account: the GET method is defined to be inherently idempotent, whereas the POST method is defined to be, at least potentially, non-idempotent; the specifications call for a number of precautions to be taken by client agents (such as browsers) for protecting users against inadvertently (re)submitting a POST transaction which they had not intended, or submitting a POST into a context which they would not have wanted .
--cut-----------
POST request must not be repeated and must be guaranteed somehow

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question