Apparently i was not including the eos bucket in the new brigade.
It seems to work:

if ($b->is_eos) {

$this->my_function(\$f->ctx->{html},$f->r,$f->c);

#new bucket brigade to be filled with final modified bucket
my $nbb = APR::Brigade->new($f->c->pool,$f->c->bucket_alloc);

#new bucket, a unique and big bucket
my $nb = APR::Bucket->new($bb->bucket_alloc,$f->ctx->{html});

#insert the new bucket and the eos bucket
$nbb->insert_tail($nb);
$nbb->insert_tail($b);

#and pass the brigade, which is not going to be parsed by this handler
$rv = $f->next->pass_brigade($nbb);
last;
}


Before this function i was not worrying about the possibility to have broken 
tags in this
handler. I say this because perhaps it is me, but i think to observe that now 
the output
is appreciably slower.

What's your opinion about to create a big bucket? As i understand, buckets were 
indeed
created to manage small pieces of info. I am doing the against. Is it very 
inefficient? Do
you suggest me to work on a streaming-approach?



>With the reading of Apache_Clean module (which i see is streamed-oriented) and 
>with ideas
>of Ambrosino, i am with this:
>sub handler : FilterRequestHandler {
>my($f, $bb) = @_;
>my $rv;
>unless ($f->ctx) {
>$f->r->headers_out->unset('Content-Length');
>$f->ctx({html => ''});
>}
>while (!$bb->is_empty) {
>my $b = $bb->first;
>$b->remove;
>if ($b->read(my $data)) {
>$f->ctx->{html} .= $data;
>}
>if ($b->is_eos) {
>$this->MYFUNCTION(\$f->ctx->{html},$f->r,$f->c);
>#new bucket brigade to be filled with modified buckets
>my $nbb = APR::Brigade->new($f->c->pool,$f->c->bucket_alloc);
>#new bucket, a unique and big bucket, is it efficient?
>$b = APR::Bucket->new($bb->bucket_alloc,$f->ctx->{html});
>$nbb->insert_tail($b);
>$rv = $f->next->pass_brigade($nbb);
>last;
>}
>}
>return $rv unless $rv == APR::Const::SUCCESS;
>Apache2::Const::OK;
>}


---------------------------------------------------------
Juega y llévate una PS2 two: 
http://juegos.ya.com/consolas_y_pc/2005/09/concurso-ps2.html
Ya.com ADSL 2MB + Llamadas 24 horas: desde 26,95 €/mes + IVA. Navega y habla de 
forma ilimitada. Sin compromiso de permanencia. 
http://acceso.ya.com/ADSLllamadas/2mb

Reply via email to