当HTTP POST被重定向到GET时,POST的主体会发生什么? [英] When an HTTP POST is redirected to GET, what happens to the body of the POST?

查看:100
本文介绍了当HTTP POST被重定向到GET时,POST的主体会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据我以前的问题,我需要将HTTP POST请求重定向到不同的服务器。我相信这可以使用PHP的HTTP响应头来完成,但我知道POST请求将成为GET请求。我的问题是HTTP请求的正文发生了什么?它会被丢弃,还是会被转换为GET请求的查询url的一部分?



即,如果一个POST被发送到 http://mysite.com/handler.php 并且我重定向到 http://othersite.com/handler。 php 会自动变成 http://othersite.com/handler.php?param1=hello&param2=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&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.

这篇关于当HTTP POST被重定向到GET时,POST的主体会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆