Joe Schaefer wrote:
Stas Bekman <[EMAIL PROTECTED]> writes:
[...]
Interesting. What's the type of the bucket? Is that a file bucket?
I believe so. File buckets morph into two buckets when you read from them. The current bucket transforms into a heap bucket, and a new file bucket is inserted behind *it*.
However, if you remove the file bucket from the brigade *before* you read from it, the morphed file bucket created during the read winds up in limbo, not in the original brigade.
Thanks Joe. I'm going to update mp2 docs.
Moving $b->remove to the end makes the code horribly kludgy. It's better to change the idiom to step through the buckets instead of removing them. Adjusting John's sample code:
my $bb = $r->upload('file')->bb(); open(OUT,">/tmp/test_file"); for (my $b = $bb->first; $b; $b = $bb->next($b)) { $b->read(my $data); print OUT $data; } close OUT;
Joe, does this idiom work fine with file buckets? We need to write a test for this case, but at the moment we have no API to create file buckets. I guess we could test that in an output filter and have a response handler call sendfile, which should create a bucket of file type.
BTW, John you could also do:
my $bb = $r->upload('file')->bb(); my $len = $bb->flatten(my $data); print OUT $data;
though it's probably less memory-usage effective.
-- __________________________________________________________________ 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