[Catalyst] HTTP::Body(::OctetScream)'s strange behaviour

Sascha Kiefer sk at intertivity.com
Tue Nov 22 16:18:33 CET 2005


I would prefer an "offset" like

$self->{buffer} || = 0;
if ( my $length = ( length( $self->{buffer} ) - $self->{offset} ) ) {
   $self->body->write( substr( $self->{buffer}, $self->{offset}, $length);
   $self->{offset} += $length;
}

Does $self->body->write return size that actually was written?
If yes, then just increment the offset by the return value of  
$self->body->write of course.

--esskar

Daisuke Murase schrieb:

>***********************
>Your mail has been scanned by InterScan VirusWall.
>***********-***********
>
>
>Hi sri, chansen.
>
>I found strange behaviour arround HTTP::Body and/or
>HTTP::Body::OctetStream.
>
>
>In HTTP::Body sub add :
>
>    $self->{buffer} .= $_[0];
>
>
>and in HTTP::Body::OctetStream sub spin:
>
>    if ( my $length = length( $self->{buffer} ) ) {
>        $self->body->write( substr( $self->{buffer}, 0, $length ),
>    }
>
>
>This is strange obviously.
>$self->body is broken when HTTP::Body->add called two times or more.
>
>
>It shuold be:
>
>-   $self->{buffer} .= $_[0];
>+   $self->{buffer} = $_[0];
>
>or
>
>    if ( my $length = length( $self->{buffer} ) ) {
>        $self->body->write( substr( $self->{buffer}, 0, $length ),
>+       $self->{buffer} = '';
>    }
>
>or something elegant fix.
>
>
>--
>Daisuke Murase <typester at cpan.org>
>
>_______________________________________________
>Catalyst mailing list
>Catalyst at lists.rawmode.org
>http://lists.rawmode.org/mailman/listinfo/catalyst
>
>
>
>  
>




More information about the Catalyst mailing list