Apache 在curl中传递POST数据时请求实体太大

Apache 在curl中传递POST数据时请求实体太大,apache,curl,http-status-code-413,fastcgi++,fedora-29,Apache,Curl,Http Status Code 413,Fastcgi++,Fedora 29,我有一个fastcgi++服务。POST需要4个参数,因为其中一个是密码。我的示例输入是61个字符。我是这样称呼我的服务的: curl --data 'name=test&address=abc&phoneNumber=0987654321&password=test123' http://localhost/cgi-bin/add-user.fcg 我收到以下错误:413请求实体太大。根据我的研究,我发现这意味着阿帕奇期待的是一个更小的身体。所以,我在httpd.co

我有一个fastcgi++服务。POST需要4个参数,因为其中一个是密码。我的示例输入是61个字符。我是这样称呼我的服务的:

curl --data 'name=test&address=abc&phoneNumber=0987654321&password=test123' http://localhost/cgi-bin/add-user.fcg
我收到以下错误:413请求实体太大。根据我的研究,我发现这意味着阿帕奇期待的是一个更小的身体。所以,我在httpd.conf中添加了
LimitRequestBody 0
(我不在生产环境中)。但是apache仍然抱怨请求实体太大

我在curl中添加了-v,这是输出:

*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 80 (#0)
> POST /cgi-bin/add-user.fcg HTTP/1.1
> Host: localhost
> User-Agent: curl/7.61.1
> Accept: */*
> Content-Length: 60
> Content-Type: application/x-www-form-urlencoded
> 
* upload completely sent off: 60 out of 60 bytes
< HTTP/1.1 413 Request Entity Too Large
< Date: Sun, 24 Mar 2019 03:48:09 GMT
< Server: Apache/2.4.38 (Fedora) mod_fcgid/2.3.9
< Connection: close
< Transfer-Encoding: chunked
< Content-Type: text/html; charset=utf-8
< 
* Closing connection 0
<!DOCTYPE html><html lang='en'><head><title>413 Request Entity Too Large</title></head><body><h1>413 Request Entity Too Large</h1></body></html>
(不是答案,但太大,无法发表评论)

如果运行这个php脚本,您会得到什么

<?php
declare(strict_types=1);
header("Content-Type: text/plain;charset=utf-8");
$ch=curl_init('http://localhost/cgi-bin/add-user.fcg');
curl_setopt_array($ch,array(CURLOPT_USERAGENT=>'curl/7.61.1',CURLOPT_RETURNTRANSFER=>1));
$post_str="";
for($i=0;$i<61;++$i){
curl_setopt_array($ch,array(
CURLOPT_POST=>1,
CURLOPT_POSTFIELDS=>$post_str,
));
curl_exec($ch);
$code=curl_getinfo($ch,CURLINFO_RESPONSE_CODE);
echo "bytes: {$i} code: {$code}\n";
$post_str.="a";
}
curl_close($ch);
echo "finished loop";

我应该提到我使用的是fastcgi++库。正如@提到的,413页不是apache的。原来是fastcgi++。我应该先看一下文件。它清楚地提到POST在默认情况下是不启用的。在我的类中添加一个构造函数,并使用我想要的最大POST请求大小调用请求构造函数,解决了这个问题


另外,非常感谢你为我调试了这么多小时

-v
添加到curl,您得到了什么?在更改conf之后是否重新启动了apache/php处理程序?Yes@Harikrishnan。读了你的评论后,我又做了一次。什么也没发生。结果是相同的,@hanshenrik60字节的问题中的-v输出太低,无法触发413错误。我认为您的apache配置错误。请在之前结束脚本输出headers@Hemil我对此表示怀疑,但没关系。。我很无聊,你现在可以通过Facebook或Discord联系我吗?想亲自看看吗?我以
Hemilr
AddHandler fcgid-script fcg fcgi fpl

Sane place to put sockets and shared memory file
FcgidIPCDir /run/mod_fcgid
FcgidProcessTableFile /run/mod_fcgid/fcgid_shm
<?php
declare(strict_types=1);
header("Content-Type: text/plain;charset=utf-8");
$ch=curl_init('http://localhost/cgi-bin/add-user.fcg');
curl_setopt_array($ch,array(CURLOPT_USERAGENT=>'curl/7.61.1',CURLOPT_RETURNTRANSFER=>1));
$post_str="";
for($i=0;$i<61;++$i){
curl_setopt_array($ch,array(
CURLOPT_POST=>1,
CURLOPT_POSTFIELDS=>$post_str,
));
curl_exec($ch);
$code=curl_getinfo($ch,CURLINFO_RESPONSE_CODE);
echo "bytes: {$i} code: {$code}\n";
$post_str.="a";
}
curl_close($ch);
echo "finished loop";