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

Daisuke Murase typester at cpan.org
Tue Nov 22 16:43:58 CET 2005


Hmm.. I think $self->{buffer} should not store whole data when large
data is posted.
It should be just a buffer, I think :)


From: Sascha Kiefer <sk at intertivity.com>
Subject: Re: [Catalyst] HTTP::Body(::OctetScream)'s strange behaviour
Date: Tue, 22 Nov 2005 16:18:33 +0100

> 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
> >
> >
> >
> >  
> >
> 
> 
> _______________________________________________
> Catalyst mailing list
> Catalyst at lists.rawmode.org
> http://lists.rawmode.org/mailman/listinfo/catalyst
> 



More information about the Catalyst mailing list