in reply to Detecting when a $CGI::POST_MAX limit is exceeded

From Custom error handling for oversized CGI request entities ...

#!/usr/bin/perl -Tw use CGI; use strict; BEGIN { my $POST_MAX = 512 * 1024; my $content_length = defined $ENV{'CONTENT_LENGTH'} ? $ENV{'CONTEN +T_LENGTH'} : 0; if ( ($POST_MAX > 0) && ($content_length > $POST_MAX) ) { # custom request entity too large error handling } }

This code block uses the same logic employed by CGI for the handling of the oversize HTTP requests, however, whereas CGI returns a 413 error, this code block can be customised in its return output.

BTW - CGI::Application rocks! :-)

 

perl -le 'print+unpack"N",pack"B32","00000000000000000000001001011111"'