I'm trying to use APR::Request outside of Apache to parse application/
x-www-form-urlencoded POST data. I'm using libapreq2-2.08.
I have some working code mostly taken from the libapreq2 tests, but
I'm running into an issue where the second time I try to parse
something, nothing is parsed. The code I'm using is below along with
the output. Is there something I'm forgetting to reset before
calling the function a second time?
#!/usr/bin/perl
use strict;
use warnings;
use APR::Pool;
use APR::Brigade;
use APR::Bucket;
use APR::BucketAlloc;
use APR::Request;
use APR::Request::Parser;
urlencoded();
urlencoded();
sub urlencoded {
my $pool = APR::Pool->new;
my $ba = APR::BucketAlloc->new($pool);
my $bb = APR::Brigade->new($pool, $ba);
my $buf = 'a=1&b=2';
$bb->insert_tail(
APR::Bucket->new( $ba, $buf )
);
warn "Parsing $buf\n";
my $parser = APR::Request::Parser->urlencoded(
$pool,
$ba,
'application/x-www-form-urlencoded',
);
my $req = APR::Request::Custom->handle(
$pool,
'',
'',
$parser,
7,
$bb,
);
my $table = $req->param;
$table->do( sub {
my ( $key, $value ) = @_;
warn "$key => $value\n";
} );
}
----
Output:
Parsing a=1&b=2
a => 1
b => 2
Parsing a=1&b=2
--
Andy Grundman
[EMAIL PROTECTED]