Invoking an OutputFilterHandler for a particular User-Agent

Invoking an OutputFilterHandler for a particular User-Agent

am 28.03.2008 15:39:27 von woinshet abdella

--0-739102356-1206715167=:15452
Content-Type: text/plain; charset=us-ascii

Hello,

I have added the following configuration in httpd.conf file to insert an output filter handler into the output filters chain for processing .html files before sending them to the client.

....
PerlRequire /usr/local/libexec/perl/startup.pl
PerlModule Apache::CustomFilterTitle

PerlOutputFilterHandler Apache::CustomFilterTitle

....
This is working as expected.
My question is, I need to find a way to invoke the handler ONLY for a particular user-agent.

Here is my environment
Red Hat Enterprise Linux
Apache/2.0.46
perl, v5.8.0

I apperciate your help

Thanks
Woinshet


____________________________________________________________ ________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?categor y=shopping
--0-739102356-1206715167=:15452
Content-Type: text/html; charset=us-ascii

Hello,

 

I have added the following configuration in httpd.conf file to insert an output filter handler into the output filters chain for processing .html files before sending them to the client.


...
PerlRequire /usr/local/libexec/perl/startup.pl
PerlModule Apache::CustomFilterTitle

<Files ~ "*\.html">
       PerlOutputFilterHandler Apache::CustomFilterTitle
</Files>
...

This is working as expected.

My question is, I need to find a way to invoke the handler ONLY for a particular user-agent.


Here is my environment

Red Hat Enterprise Linux
Apache/2.0.46
perl, v5.8.0


I apperciate your help


Thanks
Woinshet



Looking for last minute shopping deals?
Find them fast with Yahoo! Search.

--0-739102356-1206715167=:15452--

Re: Invoking an OutputFilterHandler for a particular User-Agent

am 28.03.2008 16:10:20 von torsten.foertsch

On Fri 28 Mar 2008, woinshet abdella wrote:
> PerlRequire /usr/local/libexec/perl/startup.pl
> PerlModule Apache::CustomFilterTitle
>
> =A0 =A0 =A0 =A0PerlOutputFilterHandler Apache::CustomFilterTitle
>

> ...
> This is working as expected.
> My question is, I need to find a way to invoke the handler ONLY for a
> particular user-agent.

use something like the following lines at start of your filter:

unless( $f->ctx ) {
unless( $f->r->headers_in->{'User-Agent'} eq 'Wanted' ) {
$f->remove;
return Apache2::Const::DECLINED;
}
}

Torsten

Re: Invoking an OutputFilterHandler for a particular User-Agent

am 28.03.2008 17:05:14 von woinshet abdella

--0-1285637095-1206720314=:3407
Content-Type: text/plain; charset=us-ascii

Thanks for the reply.

I know it is possible to do it inside the handler. However, for performance reasons, we want to prevent the handler from running on every request by configuring Apache.

Thanks again
Woinshet


----- Original Message ----
From: Torsten Foertsch
To: modperl@perl.apache.org
Cc: woinshet abdella
Sent: Friday, March 28, 2008 10:10:20 AM
Subject: Re: Invoking an OutputFilterHandler for a particular User-Agent

On Fri 28 Mar 2008, woinshet abdella wrote:
> PerlRequire /usr/local/libexec/perl/startup.pl
> PerlModule Apache::CustomFilterTitle
>
> PerlOutputFilterHandler Apache::CustomFilterTitle
>

> ...
> This is working as expected.
> My question is, I need to find a way to invoke the handler ONLY for a
> particular user-agent.

use something like the following lines at start of your filter:

unless( $f->ctx ) {
unless( $f->r->headers_in->{'User-Agent'} eq 'Wanted' ) {
$f->remove;
return Apache2::Const::DECLINED;
}
}

Torsten


____________________________________________________________ ________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs
--0-1285637095-1206720314=:3407
Content-Type: text/html; charset=us-ascii


Thanks for the reply.

I know it is possible to do it inside the handler. However, for performance reasons, we want to prevent the handler from running on every request  by configuring Apache.

 

Thanks again

Woinshet


----- Original Message ----
From: Torsten Foertsch <torsten.foertsch@gmx.net>
To: modperl@perl.apache.org
Cc: woinshet abdella <woinshetm@yahoo.com>
Sent: Friday, March 28, 2008 10:10:20 AM
Subject: Re: Invoking an OutputFilterHandler for a particular User-Agent

On Fri 28 Mar 2008, woinshet abdella wrote:
> PerlRequire /usr/local/libexec/perl/startup.pl
> PerlModule Apache::CustomFilterTitle
> <Files ~ "*\.html">
>        PerlOutputFilterHandler Apache::CustomFilterTitle
> </Files>
> ...
> This is working as expected.
> My question is, I need to find a way to invoke the handler ONLY for a
>
particular user-agent.

use something like the following lines at start of your filter:

unless( $f->ctx ) {
  unless(
$f->r->headers_in->{'User-Agent'} eq 'Wanted' ) {
    $f->remove;
    return Apache2::Const::DECLINED;
  }
}

Torsten




Be a better friend, newshound, and
know-it-all with Yahoo! Mobile.
--0-1285637095-1206720314=:3407--