在服务器上处理POST请求作为GET请求是否有任何问题 [英] Are there any problems handling a POST request as a GET request on the server

查看:730
本文介绍了在服务器上处理POST请求作为GET请求是否有任何问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图解决我在此问题中发布的问题:

In an attempt to resolve the issue I posted in this question:

是否可以使用system()调用将POST参数发送到CGI脚本?

到目前为止,唯一成功解决问题的办法是欺骗环境认为请求是GET。我这样做是通过将POST参数转换为查询字符串,将该字符串保存在默认环境变量中,然后更改环境变量,告诉服务器此请求用于GET的方法。

So far the only successful resolution to the problem is to trick the environment to think the request was a GET. I do this by converting the POST parameters to a query string, saving that string in the default environment variable, then changing the environment variable that tells the server what method this request is using to GET.

$ENV{'QUERY_STRING'} = $long_parameter_string . '&' . $ENV{'QUERY_STRING'};
$ENV{'REQUEST_METHOD'} = 'GET';

system {$perl_exec} $cgi_script;

我实际上是在欺骗CGI模块从QUERY_STRING环境变量而不是STDIN中读取它会尝试从中读取POST请求。

I'm essentially tricking the CGI module to read from the QUERY_STRING environment variable instead of from STDIN, which it would attempt to read POST requests from.

这种方法到目前为止似乎有效,但我担心会出现意外的后果。

This method seems to work so far, but I'm worried about unintended repercussions.

我的问题是,你认为这有什么潜在的问题吗?

My question is, do you see any potential problems with this?

推荐答案

你会遇到问题较大的提交和文件上传,因为GET的大小限制远小于POST。如果你在谈论可预测的少量数据,你应该没问题。

You'll hit problems with larger submissions and file-uploads as the size limit for a GET is much smaller than a POST. If you're talking about predictably small amounts of data, you should be alright.

这篇关于在服务器上处理POST请求作为GET请求是否有任何问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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