perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark J. Reed" <markjr...@gmail.com>
Subject Re: Suggestion on perl handler to reject request with large content length
Date Fri, 19 Nov 2010 02:33:32 GMT
Accidental tab strikes again.  Anyway, the idea is to set up the
handler to run before LimitRequestBody, if possible.  I'm not sure
what hook that is.

If you can do that, then something like this would work:

 sub handler {
    my $r = shift;
    if ($r->uri =~ /abc/) {
         $r->content_type('text/plain); # API will override this if it
gets past the LimitRequestBody
         $r->custom_response(Apache2::Const::HTTP_REQUEST_ENTITY_TOO_LARGE,
"File too large|Bye");
    } elsif ($r->uri =~ /def/) {
          $r->content_type('text/xml');
          $r->custom_response(Apache2::Const::HTTP_REQUEST_ENTITY_TOO_LARGE,"<xml><message>Bad
request</message></xml>");
   }
   return Apache2::Const::OK
}

That way you don't have to duplicate the logic of the check yourself,
you're just arranging for a customized response when it fails.

-- 
Mark J. Reed <markjreed@gmail.com>

Mime
View raw message