CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: mod_perl:
works in PerlResponseHandler, but not in PerlInputFilterHandler

 



ankurrathi
New User

Nov 27, 2010, 8:58 AM

Post #1 of 1 (18636 views)
works in PerlResponseHandler, but not in PerlInputFilterHandler Can't Post

 

Hi,

I am trying to write a mod_perl filter to read form data from post request. I found an example code:

package MyApache2::Test;

use Apache2::Filter (); # $f
use Apache2::RequestRec (); # $r
use Apache2::RequestUtil (); # $r->dir_config()
use Apache2::Log (); # $log->info()
use APR::Brigade ();
use APR::Bucket ();
use Apache2::Const -compile => qw(OK DECLINED);
use APR::Const -compile => qw(SUCCESS BLOCK_READ);
use Apache2::Const -compile => qw(MODE_READBYTES);
use Apache2::Connection ();
use constant IOBUFSIZE => 8192;
use strict;

sub handler {


my $r = shift;
#my $r = $f->r;
Apache2::ServerRec->log_error(" *** filter invoked *** ");


my $bb = APR::Brigade->new($r->pool, $r->connection->bucket_alloc);

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;

Apache2::ServerRec->log_error($data);

Apache2::ServerRec->log_error(" *** filter invoked 222 *** ");

return Apache2::Const::OK;

}
1;

The above code works if I write it into PerlResponseHandler's filter but not in PerlInputFilterHandler's filter.

I can't use PerlResponseHandler as I want response to be generated by requested resource... Can anyone let me know what shall I use here?

Thanks.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives