Re: Suggestion on perl handler to reject request with large content length

"Mark J. Reed" <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <[email protected]>
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 <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.