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


_______________________________________________
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