开发者

When an HTTP POST is redirected to GET, what happens to the body of the POST?

开发者 https://www.devze.com 2023-02-10 11:00 出处:网络
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 beco

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.c开发者_StackOverflow社区om/handler.php and I redirect to http://othersite.com/handler.php will it automatically become http://othersite.com/handler.php?param1=hello&param2=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.


If you are using CURL to redirect such a request, it is regarded as a distinct, new HTTP request that is not related to the original one at all. The only data that gets passed along is that which you explicitly pass in the query string.

0

精彩评论

暂无评论...
验证码 换一张
取 消