Mailing List Archive

Apache2 filter
Hi.

I am trying to write an Apache2 request filter.
According to the online tutorial
(http://perl.apache.org/docs/2.0/user/handlers/filters.html#Output_Filters). I have this
so far :

package MyFilter;
...
use base qw(Apache2::Filter);
...
use constant BUFF_LEN => 4096;

sub handler : FilterRequestHandler {
my $f = shift;
my $content = '';

while ($f->read(my $buffer, BUFF_LEN)) {
$content .= $buffer;
}
}

but when I compile this :

aw@arthur:~/tests$ perl -cw PAGELINKS.pm
Invalid CODE attribute: FilterRequestHandler at PAGELINKS.pm line 50.
BEGIN failed--compilation aborted at PAGELINKS.pm line 50.
aw@arthur:~/tests$

platform data (from Apache log) :
[Tue Sep 01 06:25:10 2015] [notice] Apache/2.2.16 (Debian) DAV/2 SVN/1.6.12 mod_jk/1.2.30
mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations

There are already many other mod_perl modules of all kinds running on that same server
(but not filters).

What I am missing ?

André
Re: Apache2 filter [ In reply to ]
(posted with wrond id, re-posting)

On Thu, 1 Oct 2015 19:59:34 +0200
"A. Warnier" <aw@ice-sa.com> wrote:

>
> sub handler : FilterRequestHandler {
>
> What I am missing ?
>

I get the same error when I add ': FilterRequestHandler'.

Using just 'sub handler {' instead works

FilterRequestHandler is assumed when no attribute is specified (see : http://modperlbook.org/html/25-3-2-Filter-Configuration.html)

No idea why specifying does not work, though.

--
Bien à vous, Vincent Veyron

https://marica.fr/
Suivi des contentieux juridiques, des sinistres d'assurance et des contrats
Re: Apache2 filter [ In reply to ]
perl -cw sometimes throws errors with mod_perl code - as it isn't
running in the Apache
environment...

I get the same warning testing my output filter handler when running
with -cw - but it
works well in Apache...!

On 10/1/2015 6:59 PM, A. Warnier wrote:
> Hi.
>
> I am trying to write an Apache2 request filter.
> According to the online tutorial
> (http://perl.apache.org/docs/2.0/user/handlers/filters.html#Output_Filters).
> I have this so far :
>
> package MyFilter;
> ...
> use base qw(Apache2::Filter);
> ...
> use constant BUFF_LEN => 4096;
>
> sub handler : FilterRequestHandler {
> my $f = shift;
> my $content = '';
>
> while ($f->read(my $buffer, BUFF_LEN)) {
> $content .= $buffer;
> }
> }
>
> but when I compile this :
>
> aw@arthur:~/tests$ perl -cw PAGELINKS.pm
> Invalid CODE attribute: FilterRequestHandler at PAGELINKS.pm line 50.
> BEGIN failed--compilation aborted at PAGELINKS.pm line 50.
> aw@arthur:~/tests$
>
> platform data (from Apache log) :
> [Tue Sep 01 06:25:10 2015] [notice] Apache/2.2.16 (Debian) DAV/2
> SVN/1.6.12 mod_jk/1.2.30 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4
> Perl/v5.10.1 configured -- resuming normal operations
>
> There are already many other mod_perl modules of all kinds running on
> that same server (but not filters).
>
> What I am missing ?
>
> André



--
The Wellcome Trust Sanger Institute is operated by Genome Research
Limited, a charity registered in England with number 1021457 and a
company registered in England with number 2742969, whose registered
office is 215 Euston Road, London, NW1 2BE.
Re: Apache2 filter [ In reply to ]
On 02.10.2015 10:19, James Smith wrote:
> perl -cw sometimes throws errors with mod_perl code - as it isn't running in the Apache
> environment...
>
> I get the same warning testing my output filter handler when running with -cw - but it
> works well in Apache...!

This begs for a follow-up question, which probably gets into rather arcane perl internals
but..

What does the fact of specifying an "attribute" such as
sub handler : FilterRequestHandler {
actually /do/ ?

When I wrote before that this was my first attempt at writing an Apache/mod_perl output
filter, I was not being entirely accurate. I did create and run such an output filter
before, defined as just

sub redir_filter {
..
}

but I was installing it at run-time, from a PerlAccessHandler module, via

$r->add_output_filter(\&redir_filter);

and that did not seem to be a problem.

But in this case, I would need to configure my filter in the Apache configuration, like in
this other example from the on-line mod_perl documentation :

PerlModule MyApache2::Underrun
<Location />
PerlInputFilterHandler MyApache2::Underrun::filter
SetHandler modperl
PerlResponseHandler MyApache2::Underrun::response
</Location>

So, would the presence/absence of the attribute have any effect on how it has to be
configured e.g. ?

>
> On 10/1/2015 6:59 PM, A. Warnier wrote:
>> Hi.
>>
>> I am trying to write an Apache2 request filter.
>> According to the online tutorial
>> (http://perl.apache.org/docs/2.0/user/handlers/filters.html#Output_Filters). I have this
>> so far :
>>
>> package MyFilter;
>> ...
>> use base qw(Apache2::Filter);
>> ...
>> use constant BUFF_LEN => 4096;
>>
>> sub handler : FilterRequestHandler {
>> my $f = shift;
>> my $content = '';
>>
>> while ($f->read(my $buffer, BUFF_LEN)) {
>> $content .= $buffer;
>> }
>> }
>>
>> but when I compile this :
>>
>> aw@arthur:~/tests$ perl -cw PAGELINKS.pm
>> Invalid CODE attribute: FilterRequestHandler at PAGELINKS.pm line 50.
>> BEGIN failed--compilation aborted at PAGELINKS.pm line 50.
>> aw@arthur:~/tests$
>>
>> platform data (from Apache log) :
>> [Tue Sep 01 06:25:10 2015] [notice] Apache/2.2.16 (Debian) DAV/2 SVN/1.6.12
>> mod_jk/1.2.30 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1 configured --
>> resuming normal operations
>>
>> There are already many other mod_perl modules of all kinds running on that same server
>> (but not filters).
>>
>> What I am missing ?
>>
>> André
>
>
>