@msimrial

Почему не происходит редирект при post запросе?

Если есть статья по поводу : почему при get запросе можно реализовать редирект , а при post нет , скиньте пожалуйста.
  • Вопрос задан
  • 270 просмотров
Решения вопроса 2
AxianLTD
@AxianLTD
--cut------------------
The simplest situations on the WWW are "idempotent" transactions, i.e those which can be repeated without causing any harm. These are typically "GET" transactions, either because they are retrieval of straightforward URL references (e.g 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 запрос не должен повторяться и это нужно как-то гарантировать
Ответ написан
Комментировать
Редирект зависит от того какой заголовок отдает сервер при обработке поступающего запроса, тип данного запроса не имеет влияние, то есть при GET и при POST запросе, сервер может вернуть заголовок с редиректом
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы