gpt4 book ai didi

perl - 如何在 Perl 和 FCGI 中设置 POST_MAX 限制

转载 作者:行者123 更新时间:2023-12-04 23:03:27 34 4
gpt4 key购买 nike

我正在研究如何在 Perl 和 FCGI 中设置 POST_MAX。我正在使用 perl 模块 CGI::Fast。

我发现的大多数示例都是使用 CGI 的,我认为它的工作方式不同,例如:

use strict;
use CGI;
use Fcntl qw( :DEFAULT :flock );

use constant UPLOAD_DIR => "/usr/local/apache/data/uploads";
use constant BUFFER_SIZE => 16_384;
use constant MAX_FILE_SIZE => 1_048_576; # Limit each upload to 1 MB
use constant MAX_DIR_SIZE => 100 * 1_048_576; # Limit total uploads to 100 MB
use constant MAX_OPEN_TRIES => 100;

$CGI::DISABLE_UPLOADS = 0;
$CGI::POST_MAX = MAX_FILE_SIZE;

my $q = new CGI;

提前致谢

最佳答案

CGI::FastCGI.pm 创建的 CGI 对象的子类.

因此,可以使用CGI中的特性,即Avoiding DOS Attacks :

$CGI::POST_MAX

If set to a non-negative integer, this variable puts a ceiling on the size of POSTings, in bytes. If CGI.pm detects a POST that is greater than the ceiling, it will immediately exit with an error message. This value will affect both ordinary POSTs and multipart POSTs, meaning that it limits the maximum size of file uploads as well. You should set this to a reasonably high value, such as 1 megabyte.

$CGI::DISABLE_UPLOADS

If set to a non-zero value, this will disable file uploads completely. Other fill-out form values will work as usual.

关于perl - 如何在 Perl 和 FCGI 中设置 POST_MAX 限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23288560/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com