Egor Korablev wrote:
hi

i use these routines to get POST data from form in my mp2 handler
all work fine,  but if i post a lot of text from my form i get error in
browser "Cannot find server. The Page cannot be displayed". There is nothing
in error_log.

How can i solve this problem? =)

Server Version: Apache/2.0.47 (Red Hat Linux) mod_perl/1.99_10 Perl/v5.8.0
mod_ssl/2.0.47 OpenSSL/0.9.7a DAV/2 PHP/4.3.3


sub getpost { my $r = shift; if ($r->method_number == Apache::M_POST) { my $input = inputDecode(content($r)); return $input; } return 0; }

sub content {
     my $r = shift;
      $r->setup_client_block;
     return '' unless $r->should_client_block;
     my $len = $r->headers_in->get('content-length');
     my $buf;
     $r->get_client_block($buf, $len);

You must call get_client_block() in the loop, untill you get all the data. It may return only a small chunk at a time.


Here is a better content() version which doesn't use client_block API, which is going to be deprecated in Apache 2.2 anyway. And it can help you with debug as well.

We may provide a C version later on.

use constant IOBUFSIZE => 8192;

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

# to enable debug start with: (or simply run with -trace=debug)
# t/TEST -trace=debug -start
sub ModPerl::Test::read_post {
    my $r = shift;
    my $debug = shift || 0;

    my @data = ();
    my $seen_eos = 0;
    my $filters = $r->input_filters();
    my $ba = $r->connection->bucket_alloc;
    my $bb = APR::Brigade->new($r->pool, $ba);

    my $count = 0;
    do {
        my $rv = $filters->get_brigade($bb,
            Apache::MODE_READBYTES, APR::BLOCK_READ, IOBUFSIZE);
        if ($rv != APR::SUCCESS) {
            return $rv;
        }

$count++;

warn "read_post: bb $count\n" if $debug;

        while (!$bb->empty) {
            my $buf;
            my $b = $bb->first;

$b->remove;

            if ($b->is_eos) {
                warn "read_post: EOS bucket:\n" if $debug;
                $seen_eos++;
                last;
            }

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

$bb->destroy;

} while (!$seen_eos);

    return join '', @data;
}


__________________________________________________________________ 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


-- Reporting bugs: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html



Reply via email to