[Catalyst] How to send raw HTTP response

Chris Devine chris at vistaeng.homeip.net
Sat Sep 27 22:25:51 BST 2008

-----Original Message-----
From: Matt S Trout [mailto:dbix-class at trout.me.uk]
Sent: Saturday, September 27, 2008 13:48
To: The elegant MVC web framework
Subject: Re: [Catalyst] How to send raw HTTP response

On Thu, Sep 25, 2008 at 08:35:14PM +0200, Christian Lackas wrote:
>> Hi Everybody,
>> is it possible for a controller method to directly produce the raw HTTP
>> My application generates a (potentially large)) ZIP file on the fly,
>> which I don't want to store (on disk or in memory) but rather send it
>> directly to the client while producing it.
>> In a CGI script I use Archive::Zip such as
>>     print CGI::header(...);
>>     $ZIP->writeToFileHandle(*STDOUT);
>>     for my $f (@files) {
>>         $ZIP->addFile($f, basename($f));
>>     }
>> How can I achieve something similar under Catalyst?
>Just call $c->write($chunk) with each chunk of data as you get it.
>Catalyst will automatically send headers before the first chunk for you.
>Do -not- rely on STDOUT being an appropriate filehandle to print to, that's
an accident of the engine design >and could easily go away.


Using a method like this, how would you set the filename of the downloaded
data in the browser?


>      Matt S Trout       Need help with your Catalyst or DBIx::Class
>   Technical Director
> Shadowcat Systems Ltd.  Want a managed development or deployment platform?


More information about the Catalyst mailing list