On Thursday, March 31, 2011 12:08:03 Chris Datfung wrote: > y string is always within the first 5000 bytes, but setting BUFF_LEN to > 8000 did not help as the buffer still sometimes gets cut after ~2500 bytes > or so. Do you know of any way to force the bucket to be a certain length?
To my knowledge there is no such device. But you can accumulate the content of the buckets in $f->ctx until there is enough of it. If the current brigade does not have enough data simply do not pass it on to the next filter. You have to watch out for flush end eos buckets, though. If the string you are looking for is always within the first 5000 bytes that should not cause problems. Avoid, however, to accumulate the whole response. Something like: sub filter { my ($f, $bb)=@_; my $mybb=$f->ctx; $f->ctx($mybb=APR::Brigade->new($f->r->pool, $f->c->bucket_alloc)) unless $mybb; $mybb->concat($bb); if( $mybb->lengh>=5000 ) { $mybb->flatten(my $buf); $buf=~s/.../.../; $mybb->cleanup; $mybb->insert_tail(APR::Bucket->new($mybb->bucket_alloc, $buf)); my $rc=$f->next->pass_brigade($mybb); $mybb->destroy; $f->remove; $rc==APR::Const::SUCCESS or return $rc; } return Apache2::Const::OK; } You still have to add code to check for flush and eos buckets. Torsten Förtsch -- Need professional modperl support? Hire me! (http://foertsch.name) Like fantasy? http://kabatinte.net