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 = IO::Uncompress::Gunzip->new( \$gzipped_data); #Assuming scalar
my $length = $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 ) = @_;

        my $uncompressed = "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
mose...@hank.org <mailto:mose...@hank.org>


_______________________________________________
List: Catalyst@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.uk/
Dev site: http://dev.catalyst.perl.org/



---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com
_______________________________________________
List: Catalyst@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.uk/
Dev site: http://dev.catalyst.perl.org/

Reply via email to