Greetings,
I'm relatively new to mod_perl, so please forgive the ignorance.
I've managed to create an output filter, but I'm having a problem with an
input filter. The error I get is as per the subject line.
Here's the code:
apache config
Perlrequire /opt/code/scripts/apache2-perl-startup.pl
...
PerlOutputFilterHandler ZCRM::OFilter::output
PerlInputFilterHandler ZCRM::OFilter::input
And here's the perl code (output filter works fine, but the input
filter results in the error below)
package ZCRM::OFilter;
use strict;
use warnings;
use Apache2::Filter ();
use Apache2::RequestRec ();
use Apache2::Const -compile => qw(OK DECLINED MODE_READBYTES);
use APR::Const -compile => qw(SUCCESS BLOCK_READ);
use Apache2::Connection ();
use constant IOBUFSIZE => 8192;
use strict;
sub output {
my $f = shift;
my $r = $f->r;
while ( $f->read( my $buffer, 1024 ) ) {
# do work on $buffer...
$f->print($buffer);
}
return Apache2::Const::OK;
}
sub input {
my $r = shift;
my $bb = APR::Brigade->new( $r->pool,
$r->connection->bucket_alloc); # <--- Line XX - ERROR here
my $data = '';
my $seen_eos = 0;
do {
$r->input_filters->get_brigade( $bb, Apache2::Const::MODE_READBYTES,
APR::Const::BLOCK_READ, IOBUFSIZE );
for ( my $b = $bb->first ; $b ; $b = $bb->next($b)) {
if ( $b->is_eos ) {
$seen_eos++;
last;
}
if ( $b->read( my $buf ) ) {
$data .= $buf;
}
$b->remove; # optimization to reuse memory
}
} while ( !$seen_eos );
$bb->destroy;
return $data;
}
1;
I would appreciate any pointers.
Thanks
Henk
I'm relatively new to mod_perl, so please forgive the ignorance.
I've managed to create an output filter, but I'm having a problem with an
input filter. The error I get is as per the subject line.
Here's the code:
apache config
Perlrequire /opt/code/scripts/apache2-perl-startup.pl
...
PerlOutputFilterHandler ZCRM::OFilter::output
PerlInputFilterHandler ZCRM::OFilter::input
And here's the perl code (output filter works fine, but the input
filter results in the error below)
package ZCRM::OFilter;
use strict;
use warnings;
use Apache2::Filter ();
use Apache2::RequestRec ();
use Apache2::Const -compile => qw(OK DECLINED MODE_READBYTES);
use APR::Const -compile => qw(SUCCESS BLOCK_READ);
use Apache2::Connection ();
use constant IOBUFSIZE => 8192;
use strict;
sub output {
my $f = shift;
my $r = $f->r;
while ( $f->read( my $buffer, 1024 ) ) {
# do work on $buffer...
$f->print($buffer);
}
return Apache2::Const::OK;
}
sub input {
my $r = shift;
my $bb = APR::Brigade->new( $r->pool,
$r->connection->bucket_alloc); # <--- Line XX - ERROR here
my $data = '';
my $seen_eos = 0;
do {
$r->input_filters->get_brigade( $bb, Apache2::Const::MODE_READBYTES,
APR::Const::BLOCK_READ, IOBUFSIZE );
for ( my $b = $bb->first ; $b ; $b = $bb->next($b)) {
if ( $b->is_eos ) {
$seen_eos++;
last;
}
if ( $b->read( my $buf ) ) {
$data .= $buf;
}
$b->remove; # optimization to reuse memory
}
} while ( !$seen_eos );
$bb->destroy;
return $data;
}
1;
I would appreciate any pointers.
Thanks
Henk