Re: filter->remove

Re: filter->remove

am 18.04.2008 15:51:51 von woinshet abdella

--0-956394884-1208526711=:78025
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

=0A----- Original Message ----=0AFrom: Torsten Foertsch tsch@gmx.net>=0ATo: woinshet abdella =0ACc: modperl@pe=
rl.apache.org=0ASent: Friday, April 18, 2008 3:35:02 AM=0ASubject: Re: filt=
er->remove On Thu 17 Apr 2008, woinshet abdella wrote:=0A> I am sorry =
to write you directly, but did not get any response from the=0A> modperl us=
er list. I would appreciate you help in advance! Please ask on the mod=
perl list in the future. If you don't get an answer try =0Ait again. We all=
are sometimes too busy to answer questions on the list. So =0Abe patient, =
polite but insistent. > Last time you send me the following code. I tr=
ied it for the last serveral=0A> days but I did not succeed, it is not REMO=
VING the filter from the chain=0A>=0A> unless($f->ctx ) {=0A> =A0 unless( $=
f->r->headers_in->{'User-Agent'} eq 'Wanted' ) {=0A> =A0 =A0 $f->remove;=0A=
> =A0 =A0 return Apache2::Const::DECLINED;=0A> =A0 }=0A> }=0A>=0A> Environm=
ent:=0A>=0A> Red Hat Enterprise Linux=0A> Apache/2.0.46=0A> perl, v5.8.0=0A=
=0AThose are quite old. If your mod_perl is that old as well that may be th=
e =0Areason. =0AThank you for your detailed explanation and identifying my =
problem. I think I am using an=A0old mod_perl. Earlier I have been using Ap=
ache::Filter in my module, when I changed it to Apache2::Filter, I get the =
following errors.  =0A...=0ACan't locate Apache2/Filter.pm in @INC (@IN=
C contains: /usr/local/libexec/perl /usr/lib/perl5/5.8.0/i38=0A....=0ASo, I=
am not able to use=A0$f->remove with old mod_perl, is that correct?=0AThan=
ks.=0AWoinshet=0AI have attached 2 very simple modules that I have used for=
some time. =0AApache2::PrintFilterChain prints the current output filter c=
hain to the =0Aerror_log. Apache2::Remove... removes the next filter in the=
chain if the =0Acontent type of the document being delivered is not text/h=
tml. Both modules =0Aremove themselves on the first invocation. Hence they =
are called only once =0Aper document. PerlOutputFilterHandler Apache2:=
:PrintFilterChain=0APerlOutputFilterHandler Apache2::RemoveNextFilterIfNotT=
extHtml=0APerlSetOutputFilter INCLUDES=0APerlOutputFilterHandler Apache2::P=
rintFilterChain If used on a HTML document you should see in the outpu=
t of the first =0Ainvocation of PrintFilterChain 2 times PrintFilterChain, =
once the filter =0Aremoving filter and once INCLUDES. The second PrintFilte=
rChain will show =0AINCLUDES and one PrintFilterChain: Here an output =
example for text/plain: Filter Chain:   modperl_request_output=A0 =
=A0 =A0 =A0 =A0 <-- the first PrintFilterChain   modperl_request_output=
=A0 =A0 =A0 =A0 =A0 <-- RemoveNextFilterIfNotTextHtml   includes   =
modperl_request_output=A0 =A0 =A0 =A0 =A0 <-- PrintFilterChain again   =
byterange   content_length   http_header   http_outerror   =
log_input_output   core Filter Chain:   modperl_request_output=
=A0 =A0 =A0 =A0 =A0 <-- the second PrintFilterChain   byterange   c=
ontent_length   http_header   http_outerror   log_input_output=
  core You see the 3 filters above the second PrintFilterChain ha=
ve gone. Now a text/html doc: Filter Chain:=A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 <-- the 1st invocation sees the same chain   mo=
dperl_request_output   modperl_request_output   includes   modp=
erl_request_output   byterange   content_length   http_header=
  http_outerror   log_input_output   core Filter Chain:=
  includes=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 <-- but now =
the includes filter remains   modperl_request_output   byterange=0A=
=A0 content_length   http_header   http_outerror   log_input_ou=
tput   core =0AHope that helps. Torsten --=0ANeed profes=
sional mod_perl support?=0AJust hire me: torsten.foertsch@gmx.net =0A=
=0A ____________________________________________________________ ______=
__________________=0ABe a better friend, newshound, and =0Aknow-it-all with=
Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=3DAhu06i62sR8HD=
tDypao8Wcj9tAcJ
--0-956394884-1208526711=:78025
Content-Type: text/html; charset=us-ascii



 

----- Original Message ----
From: Torsten Foertsch <torsten.foertsch@gmx.net>
To: woinshet abdella <woinshetm@yahoo.com>
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 t
he 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 PrintFilterCha
in 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
<
BR>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: torsten.foertsch@g mx.net




Be a better friend, newshound, and
know-it-all with Yahoo! Mobile.
--0-956394884-1208526711=:78025--