Add native size limiting to WebGUI via plack. This is no longer a WRE specific feature.

This commit is contained in:
Colin Kuskie 2011-12-31 19:01:25 -08:00
parent 55a05e99fa
commit 03a22421a7
3 changed files with 11 additions and 0 deletions

View file

@ -66,6 +66,9 @@ sub call {
my $self = shift;
my $env = shift;
##Enable size limiting
$env->{'psgix.harakiri'} = 1;
my $session = $env->{'webgui.session'}
or die 'Missing WebGUI Session - check WebGUI::Middleware::Session';

View file

@ -184,6 +184,7 @@ checkModule('Data::ICal', '0.16' );
checkModule('common::sense', '3.2' );
checkModule('Geo::Coder::Googlev3', '0.07' );
checkModule('IO::File::WithPath', );
checkModule('Plack::Middleware::SizeLimit', );
failAndExit("Required modules are missing, running no more checks.") if $missingModule;

View file

@ -8,6 +8,13 @@ builder {
my $config = $wg->config;
my $streaming_uploads = $config->get('enableStreamingUploads'); # have to restart for changes to this to take effect
if (! $^O eq 'darwin') {
enable 'Plack::Middleware::SizeLimit' => (
max_unshared_size => 200_000,
max_process_size => 500_000,
check_every_n_requests => 3,
);
}
enable 'Log4perl', category => $config->getFilename, conf => WebGUI::Paths->logConfig;
enable 'SimpleContentFilter', filter => sub {
if ( utf8::is_utf8($_) ) {