我有一个fastcgi ++服务。通过POST需要4个参数,因为其中一个是密码。我的示例输入是61个字符。这就是我打电话给我的服务的方式:
2019-02-01 11:44:00
我收到此错误: 413请求实体太大。根据我的研究,我发现这意味着apache期望的身体比现在要小。因此,我在httpd.conf中添加了curl --data 'name=test&address=abc&phoneNumber=0987654321&password=test123' http://localhost/cgi-bin/add-user.fcg
(我不在生产环境中)。但是apache仍然抱怨请求实体太大。
我将-v添加到curl,这是输出:
LimitRequestBody 0
这是我的httpd.conf:
* 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>
这是fcgid.conf:
ServerRoot "/etc/httpd"
Listen 80
Include conf.modules.d/*.conf
User apache
Group apache
ServerAdmin root@localhost
<Directory />
AllowOverride none
Require all denied
</Directory>
DocumentRoot "/var/www/html"
<Directory "/var/www">
AllowOverride None
# Allow open access:
Require all granted
</Directory>
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
<Files ".ht*">
Require all denied
</Files>
ErrorLog "logs/error_log"
LogLevel warn
<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
CustomLog "logs/access_log" combined
</IfModule>
<IfModule alias_module>
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
</IfModule>
<Directory "/var/www/cgi-bin">
AllowOverride None
Options +ExecCGI
Require all granted
SetHandler fcgid-script
</Directory>
<IfModule mime_module>
TypesConfig /etc/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</IfModule>
AddDefaultCharset UTF-8
<IfModule mime_magic_module>
MIMEMagicFile conf/magic
</IfModule>
EnableSendfile on
IncludeOptional conf.d/*.conf
#I added the line below
LimitRequestBody 0
答案 0 :(得分:2)
我应该提到我正在使用fastcgi ++库。正如@ covener所提到的,413页不是apache的。原来是fastcgi ++。我应该先阅读文档。它明确提到here,默认情况下未启用POST。在我的类中添加一个构造函数,并以所需的POST请求的最大大小调用Request构造函数,即可解决此问题。
P.S。 @ hansherik非常感谢您为我所做的所有调试工作。
答案 1 :(得分:0)
(不是答案,但太大而无法发表评论)
如果运行此php脚本,您会得到什么?
{
"$type": "Person",
"id": 8,
"firstName": "Anke",
"lastName": "Winkler",
…
}