Udo Rader wrote:
Because get_client_block must be called in a loop. That's how Apache implements it:hi,I see that the new version of mod_perl has $r->read fixed now to read exactly the given bytes. $r->get_client_block however is still buggy. If for example I do the following: --------CUT-------- my $len = $r->headers_in->{'content-length'}; print "reported length is $len<br>"; my $buf; $r->get_client_block( $buf, $len ); print "read length is: ".length($buf)."<br>"; --------CUT-------- ... then I get extremely different values for the reported and the read length. This does _not_ happen on small amounts of data, I think the threshold is somewhere near 7K of data pending to be read. The example works perfect, if I use $r->read instead, so I am quite happy with 1.99_08 ;-)
/* get_client_block is called in a loop to get the request message body.
* This is quite simple if the client includes a content-length
* (the normal case), but gets messy if the body is chunked. Note that
* r->remaining is used to maintain state across calls and that
* r->read_length is the total number of bytes given to the caller
* across all invocations. It is messy because we have to be careful not
* to read past the data provided by the client, since these reads block.
* Returns 0 on End-of-body, -1 on error or premature chunk end.
*
*/
Here is an example we use in the test suite to read the the request body:
sub ModPerl::Test::read_post {
my $r = shift;
$r->setup_client_block;
return undef unless $r->should_client_block;
my $data = '';
my $buf;
while (my $read_len = $r->get_client_block($buf, IOBUFSIZE)) {
if ($read_len == -1) {
die "some error while reading with get_client_block";
}
$data .= $buf;
}
return $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