Matt Avitable wrote:
Hi list :-)

Does anyone know how one goes about disabling a particular handler within a specific location? For example, consider the following:

   <Location />
        PerlInitHandler config
        PerlOutputFilterHandler filter
    </Location>

   <LocationMatch "/(images|gfx)/">
    ## what can I put here to say "don't run" to the above handlers?
   </Location>

## OR

    <Files ~ "\.(jpg|jpe?g|gif|png)$">
        ## something here...
    </Files>

For all HTTP requests for files everywhere excluding directories with /images/ and /gfx/ in it, I want to
run my PerlInitHandler and my PerlOutputFilterHandler. All my handlers do is set up some config variables
and run an xml filter. It's useless overhead to run these handlers on images.

This is not really a mp2 specific question I believe, unless I'm missing something. You have to do the same in mp1.


I guess there might be a way to do that, but the simplest idiomatic modperl approach is to make the decisions once you are inside the Init handler.

  <Location />
         PerlInitHandler Foo::handler
  </Location>

package Foo;
# load the modules/constants here
sub handler {
  my $r = shift;
  return Apache::DECLINED if $r->uri =~ /(?:jpe?g|gif|png)$/;
  $r->push_handlers(PerlOutputFilterHandler => \&filter_handler);
  return Apache::OK;
}
1;

p.s. I've optimized your /jpg|jpe?g/ regex ;)

Also you may need this :)
http://perl.apache.org/docs/2.0/api/ModPerl/MethodLookup.html

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com



Reply via email to