gpt4 book ai didi

php - 浏览器可以使用 POST 重定向到 url 吗?

转载 作者:可可西里 更新时间:2023-11-01 17:15:02 25 4
gpt4 key购买 nike

我在一个将我重定向到我自己的网络服务器 (www.myserver.com) 的页面上,但请求不是 GET 而是 POST。

起初 www.myserver.com 无法处理请求,因为我只有一个用于处理“GET/”的路由处理器。当我意识到它可能是一个 POST 重定向(在他们的指南中阅读它)时,我为“POST/”创建了一个路由处理程序并且页面被提供了。

如果我错了请更正我,以便浏览器可以使用 POST 重定向到一个 url?

最佳答案

答案是肯定的,但浏览器应该提示用户。除了 GET 和 HEAD 允许使用 302,POST 允许使用 307。来自 HTTP RFC:

307临时重定向

The requested resource resides temporarily under a different URI. Since the redirection MAY be altered on occasion, the client SHOULD continue to use the Request-URI for future requests. This response is only cacheable if indicated by a Cache-Control or Expires header field.

The temporary URI SHOULD be given by the Location field in the response. Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s) , since many pre-HTTP/1.1 user agents do not understand the 307 status. Therefore, the note SHOULD contain the information necessary for a user to repeat the original request on the new URI.

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.

您使用的是什么浏览器?

关于php - 浏览器可以使用 POST 重定向到 url 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4965251/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com