Serving a response in Catalyst is pretty easy. Usually, we either stuff
a scalar into the response body, or just let the view take care of it like
this:
$c->res->body('dude, what's up?');
$c->forward($c->view); # Or just let RenderView handle it
# As is the default.
However, sometimes this is not practical for your purpose. Maybe you
need to serve a streaming mp3, or you have a big file that you don't want
to load into memory all at once... Fixing this is just as easy, tho.
my $fh=io('/tmp/bigfile');
$c->res->body($fh);
and presto, Catalyst will serve the response from the filehandle. Of course
you will have to tell catalyst how much data you expect $fh to contain
since the headers are written before the response body.
$c->res->content_length(-s $file)
Would be a simple example of how to do that.