Re: [mp2] disabling a perl handler within a specific location

2003-03-04 Thread Thomas Klausner
Hi!

On Tue, Mar 04, 2003 at 12:54:30AM -0500, Matt Avitable wrote:

 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

This works for Auth*Handlers, so it should work for any phase:

LocationMatch /(images|gfx)/
   PerlInitHandler Apache::Constants::OK
/Location

See recipy 7.3 in the Cookbook


-- 
#!/usr/bin/perl   http://domm.zsi.at
for(ref bless{},just'another'perl'hacker){s-:+-$-gprint$_.$/}


[mp2] disabling a perl handler within a specific location

2003-03-03 Thread Matt Avitable
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.

I'd change the directory structure so the image dirs and the perl 
locations don't overlap, but its just not practical for this app.
I figure I can test for file/mime types of the requested file in my 
handlers, but I'd love to be able to deal with this issue from within 
httpd.conf.

Here is my setup, in case you need it:
mp 1.99_08
apache 2.0.44
Linux RH  7.2
I would appreciate any thoughts about this at all!  Even a 'I think 
your going about this entirely the wrong way' would be helpful.  This 
is all development software I'm working on, so I'm free to change alot.

Thanks!

-m

## Matt J. Avitable ([EMAIL PROTECTED])
## General Partner / Programmer
## Escapement Arts And Media
## http://www.escapement.net/
## Phone: (804) 400-0605


Re: [mp2] disabling a perl handler within a specific location

2003-03-03 Thread Stas Bekman
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 BekmanJAm_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