[Catalyst] How to send raw HTTP response
Tomas Doran
bobtfish at bobtfish.net
Sun Sep 28 17:21:41 BST 2008
On 27 Sep 2008, at 19:48, Matt S Trout wrote:
> 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.
Unfortunately, if you're using Archive::Zip, you don't get an option
to get chunks you can call $c->write with, you _need_ to write to a
file handle.. (And this isn't the only module on CPAN that'd behave
like this).
Therefore, in some cases it would be extremely useful if you could
get Catalyst to generate you a file handle you could write to that
would write directly into the HTTP response, rather than having to
call $c->write. How feasible is that?
Alternatively, it would be really useful to have an
IO::WriteOnlyClosure module, so you could say something like:
my $fh = IO::WriteOnlyClosure->new(sub { $c->write(@_[0]) });
$zip->writeToFileHandle($fh);
$zip->addfile($_, basename($_) for (@files);
Thoughts / pointing out the module I missed on CPAN?
Cheers
t0m
More information about the Catalyst
mailing list