in reply to Re: CGI.PM File Upload
in thread CGI.PM File Upload

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

Replies are listed 'Best First'.
Re: Re: Re: CGI.PM File Upload
by Anonymous Monk on Dec 05, 2002 at 04:12 UTC
    This is most helpfull, thank you !