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é




Reply via email to