Speaking of downloads, I have a gzipped file.  Well, it's a file in memory.

If I see Accept-Encoding that includes "gzip" it's easy.  I simply return
the content and set Content-Encoding: gzip and set the content length.

But, if the client does not accept gzip I uncompress it
using IO::Uncompress::Gunzip.

IO::Uncompress::Gunzip looks like a IO::File handle.  So, I can do:

$c->res->body( IO::Uncompress::Gunzip->new( \$gzipped_data ) );

Apache will add the header "Transfer-Encoding: chunked" because there's no
Content-Length header.


This works, but Catalyst in finalize_headers issues two warnings:

-s on unopened filehandle GEN10 at
/home/bill/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/Catalyst.pm
line 1893.

[warn] Serving filehandle without a content-length



Are those warning a problem with how Catalyst is handling this, or
something wrong with how IO::Uncompress::Gunzip is working?


The uncompressed file could be quite large, which is why I'd prefer to not
uncompress it in memory.   I suppose I could uncompress to /tmp and then
serve the file from there.

Of course, not using Catalyst to serve large files is perhaps another
solution.



-- 
Bill Moseley
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/

Reply via email to