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. 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]
PrintFilterChain.pm
Description: application/perl-module
RemoveNextFilterIfNotTextHtml.pm
Description: application/perl-module