Carl Brewer wrote:


Stas et all,

Here's the code that I was using to grab POSTed values and
put them into a hash 0 sorry for the verbosity of this post,
I won't pretend to fully understand this code, Stas wrote
the majority of it way back when libapreq wouldn't compile
on NetBSD, and I've been using it ever since.

            my $status = $b->read($buf);
            warn "DATA bucket: [$buf]\n" if $debug;
            if ($status != APR::SUCCESS) {
                return $status;

That's your problem. Please see: http://perl.apache.org/docs/2.0/api/APR/Bucket.html#C_read_ The API of read has changed.

The new way to implement $r->content is:

use APR::Brigade ();
use APR::Bucket ();
use Apache::Filter ();

use Apache::Const -compile => qw(MODE_READBYTES);
use APR::Const    -compile => qw(SUCCESS BLOCK_READ);

use constant IOBUFSIZE => 8192;

sub content {
    my $r = shift;

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

    my $data = '';
    my $seen_eos = 0;
    do {
        $r->input_filters->get_brigade($bb, Apache::MODE_READBYTES,
                                       APR::BLOCK_READ, IOBUFSIZE);
        while (!$bb->is_empty) {
            my $b = $bb->first;

            if ($b->is_eos) {
                $seen_eos++;
                last;
            }

            if ($b->read(my $buf)) {
                $data .= $buf;
            }

            $b->delete;
        }
    } while (!$seen_eos);

    $bb->destroy;

    return $data;
}

I'm thinking that it might be beneficial to implement it in C.


-- __________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com

--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html



Reply via email to