in reply to CGI.PM File Upload

Assuming you've set $CGI::POST_MAX correctly, it should return a 413 error if there's a CONTENT_LENGTH header and if the reported length exceeds the max.

If you haven't simply forgotten the underscore, you'll have to post your code before anyone can do more than guess.

Replies are listed 'Best First'.
Re: Re: CGI.PM File Upload
by tachyon (Chancellor) on Dec 05, 2002 at 03:27 UTC

    Actually this is wrong. What CGI.pm does is this:

    if (($POST_MAX > 0) && ($content_length > $POST_MAX)) { $self->cgi_error("413 Request entity too large"); last METHOD; sub cgi_error { my ( $self, $err ) = @_; if ( $err ) { $self->{'.cgi_error'} = $err; $self->{'.globals'}->{'FATAL'} == 1 ? croak $err : $self->{'.globals'}->{'FATAL'} == 0 ? carp $err : return +$err; } return $self->{'.cgi_error'}; }

    What this achieves is to set the cgi_error() method which behaves depending on $CGI::FATAL. A 413 header is not generated. All that generally happens is that CGI.pm exits its multipart parsing loop (METHOD:) and proceeds happily along (unless it croaked in cgi_error). As it has not got any data it end up doing zip. With no params the general behaviour written into most CGIs is to display the default/login page....

    All that is required is to check for this error and do whatever....

    my $q = new CGI; do_file_too_big() if $q->cgi_error =~ m/413/;

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      This is most helpfull, thank you !