PHP redirection with code 307 changes method from POST to GET

后端 未结 2 702
没有蜡笔的小新
没有蜡笔的小新 2021-01-22 01:02

In my PHP software I have an self-update feature which sends a HTTP request with the POST method to a certain URL (to a PHP script). Now this URL has changed (I moved the script

2条回答
  •  梦谈多话
    2021-01-22 01:44

    The W3C HTTP/1.1 specification for 307 states:

    If the 307 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.

    The point behind this is that it is unsafe for a server to tell a client to POST to a different URL as that may be a malicious attempt to get the client to send data somewhere the user did not intend, so POST redirections are not possible.

提交回复
热议问题