On Sat 01 Aug 2009, Mike Barborak wrote:
> Invalid per-directory PerlOption: InputFilter
>
> so it seems that while PerlOption is allowed at the directory level,
> the InputFilter and OutputFilter options are not. (i actually
> couldn't find a relevant section in the docs about that so i am
> unsure.)

This might quite be true.

> it is my preferred solution to be able to turn the filter off for
> particular directories via the conf file so it is my fading hope that
> i'm doing something wrong?
>
> if i am not then my plan of attack is to use PerlSetVar. then my conf
> file would look like so:
>
> <Directory /var/www/vhosts/mydomain.com/httpdocs/test>
>        PerlSetVar EnableMyFilter false
> </Directory>
>
> and my input and output filter handlers would look something like
> this:
>
> sub handler : FilterRequestHandler
> {
>         my $f = shift;
>
>         return Apache2::Const::DECLINED if $f->r->dir_config (
> 'EnableMyFilter' ) eq 'false';
>
>         ...
> }
>
> does that approach sound correct?

Almost, it would be better to have the filter remove itself on first 
invocation if it's not needed. A typical filter of mine looks like 
this:

  my $ctx=$f->ctx;

  unless( defined $ctx ) {
    unless( check_conditions($f) ) {
      $f->remove;
      return Apache2::Const::DECLINED;
    }
    $f->ctx($ctx=[]);
    $f->r->headers_out->unset('Content-Length');
  }
  ...

$f->ctx is undefined on first invocation. So, unless defined $ctx I can 
run checks that need to be done only once. If one of the conditions is 
not met the filter removes itself and returns DECLINED.

You'll have to place your PerlVar check instead of check_conditions.

> or is that i need to add an enabling / disabling filter into the
> filter chain in front of my filter that reads the PerlSetVar option
> and then either leaves my filter in the chain or uses something like
> "$f->next->next...->remove" to remove it?

No, this is only a last resort if you cannot change the filter itself.

Torsten

-- 
Need professional mod_perl support?
Just hire me: torsten.foert...@gmx.net

Reply via email to