----- Original Message ----
From: Torsten Foertsch <[EMAIL PROTECTED]>
To: woinshet abdella <[EMAIL PROTECTED]>
Cc: modperl@perl.apache.org
Sent: Friday, April 18, 2008 3:35:02 AM
Subject: Re: filter->remove
On Thu 17 Apr 2008, woinshet abdella wrote:
> I am sorry to write you directly, but did not get any response from the
> modperl user list. I would appreciate you help in advance!
Please ask on the modperl list in the future. If you don't get an answer try
it again. We all are sometimes too busy to answer questions on the list. So
be patient, polite but insistent.
> Last time you send me the following code. I tried it for the last serveral
> days but I did not succeed, it is not REMOVING the filter from the chain
>
> unless($f->ctx ) {
> unless( $f->r->headers_in->{'User-Agent'} eq 'Wanted' ) {
> $f->remove;
> return Apache2::Const::DECLINED;
> }
> }
>
> Environment:
>
> Red Hat Enterprise Linux
> Apache/2.0.46
> perl, v5.8.0
Those are quite old. If your mod_perl is that old as well that may be the
reason.
Thank you for your detailed explanation and identifying my problem. I think I
am using an old mod_perl. Earlier I have been using Apache::Filter in my
module, when I changed it to Apache2::Filter, I get the following errors.
...
Can't locate Apache2/Filter.pm in @INC (@INC contains: /usr/local/libexec/perl
/usr/lib/perl5/5.8.0/i38
....
So, I am not able to use $f->remove with old mod_perl, is that correct?
Thanks.
Woinshet
I have attached 2 very simple modules that I have used for some time.
Apache2::PrintFilterChain prints the current output filter chain to the
error_log. Apache2::Remove... removes the next filter in the chain if the
content type of the document being delivered is not text/html. Both modules
remove themselves on the first invocation. Hence they are called only once
per document.
PerlOutputFilterHandler Apache2::PrintFilterChain
PerlOutputFilterHandler Apache2::RemoveNextFilterIfNotTextHtml
PerlSetOutputFilter INCLUDES
PerlOutputFilterHandler Apache2::PrintFilterChain
If used on a HTML document you should see in the output of the first
invocation of PrintFilterChain 2 times PrintFilterChain, once the filter
removing filter and once INCLUDES. The second PrintFilterChain will show
INCLUDES and one PrintFilterChain:
Here an output example for text/plain:
Filter Chain:
modperl_request_output <-- the first PrintFilterChain
modperl_request_output <-- RemoveNextFilterIfNotTextHtml
includes
modperl_request_output <-- PrintFilterChain again
byterange
content_length
http_header
http_outerror
log_input_output
core
Filter Chain:
modperl_request_output <-- the second PrintFilterChain
byterange
content_length
http_header
http_outerror
log_input_output
core
You see the 3 filters above the second PrintFilterChain have gone.
Now a text/html doc:
Filter Chain: <-- the 1st invocation sees the same chain
modperl_request_output
modperl_request_output
includes
modperl_request_output
byterange
content_length
http_header
http_outerror
log_input_output
core
Filter Chain:
includes <-- but now the includes filter remains
modperl_request_output
byterange
content_length
http_header
http_outerror
log_input_output
core
Hope that helps.
Torsten
--
Need professional mod_perl support?
Just hire me: [EMAIL PROTECTED]
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now.
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ