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

Bill Moseley moseley at hank.org
Tue Nov 19 19:52:36 GMT 2013


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
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20131119/d86ce=
7c5/attachment.htm


More information about the Catalyst mailing list