当HTTP POST被重定向到GET时,POST的主体会发生什么? [英] When an HTTP POST is redirected to GET, what happens to the body of the POST?
问题描述
即,如果一个POST被发送到 http://mysite.com/handler.php
并且我重定向到 http://othersite.com/handler。 php
会自动变成 http://othersite.com/handler.php?param1=hello¶m2=world
POST数据消失。除非重定向脚本采取措施将POST数据推送到GET的URL或cookie中,否则数据已经死了并且没有了。
这是有点设计的。大多数浏览器限制URL的长度,并且POST对被POST数据的大小没有实际限制,因此您不希望刚刚上传的500MB文件附加到GET URL的查询行。
As per my previous question, I need to redirect an HTTP POST request to a different server. I believe this can be done using HTTP response headers from php, but I understand the POST request will become a GET request. My question is what happens to the body of the HTTP request? is it discarded, or will it be converted to be part of the GET request's query url?
i.e. if a POST is made to http://mysite.com/handler.php
and I redirect to http://othersite.com/handler.php
will it automatically become http://othersite.com/handler.php?param1=hello¶m2=world
The POST data vanishes. Unless the redirecting script takes steps to push the POST data into the GET's URL or into a cookie, the data's dead and gone.
This is somewhat by design. Most browsers limit the length of a URL, and POSTs have effectively no limit to the size of the data being POSTed, so you wouldn't want that 500megabyte file you just uploaded appended to the GET url's query line.
这篇关于当HTTP POST被重定向到GET时,POST的主体会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!