[Catalyst] Setting file handle as the response body generates warnings.

neil.lunn neil at mylunn.id.au
Wed Nov 20 12:08:57 GMT 2013


On 20/11/2013 3:01 PM, Bill Moseley wrote:
>
> I just updated:
>
> $ perl -MCatalyst -le 'print Catalyst->VERSION'
> 5.90051
>
>  I can debug more in the morning -- anything specific I should look at?
I think the stat operators have this problem on any type of in memory =

filehandle. That is pretty easy to reproduce.
To me anyhow this wouldn't seem to make much sense to me to test the =

length of a yet uncompressed filehandle, even if it did just work somehow.

For my money I would do the following:

my $body =3D IO::Uncompress::Gunzip->new( \$gzipped_data); #Assuming scalar
my $length =3D $body->getHeaderInfo->{ISIZE};
$c->res->content_length( $length );
$c->res->body( $body );

So basically getting the length of the uncompressed data from the handle =

by the object method. So now Catalyst won't try to set the size because =

you already have. Oh, and the content type and well of course :)



>
> It's pretty easy to reproduce:
>
>     package Zip::Controller::Root;
>     ...
>
>     use IO::Uncompress::Gunzip;
>     use IO::Compress::Gzip qw/ gzip $GzipError /;
>
>     sub uncompress : Local {
>         my ( $self, $c ) =3D @_;
>
>         my $uncompressed =3D "This is some text that can be
>     compressed.\n" x 5;
>         my $compressed;
>         gzip( \$uncompressed, \$compressed ) || die $GzipError;
>
>         $c->res->body( IO::Uncompress::Gunzip->new( \$compressed ) );
>         return;
>     }
>
>
>
> $ script/zip_test.pl <http://zip_test.pl> /uncompress
>
> -s on unopened filehandle GEN2 at =

> /home/bill/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/Catalyst=
.pm =

> line 1948, <DATA> line 1000.
> [warn] Serving filehandle without a content-length
> This is some text that can be compressed.
> This is some text that can be compressed.
> This is some text that can be compressed.
> This is some text that can be compressed.
> This is some text that can be compressed.
>
>
> -- =

> Bill Moseley
> moseley at hank.org <mailto:moseley at hank.org>
>
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.u=
k/
> Dev site: http://dev.catalyst.perl.org/



---
This email is free from viruses and malware because avast! Antivirus protec=
tion is active.
http://www.avast.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20131120/0ae62=
dbe/attachment.htm


More information about the Catalyst mailing list