And maybe you should also use chunked encoding for sending big files, so mojo will not hold it in memory.
Also you can use ->serve_static for serving static files.
> --
> You received this message because you are subscribed to the Google Groups "Mojolicious" group.
> To post to this group, send email to mojol...@googlegroups.com.
> To unsubscribe from this group, send email to mojolicious...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mojolicious?hl=en.
>
$res->content->asset(Mojo::Asset::File->new(path => 'lalala/foo.zip'));
On Jun 1, 2010, at 1:47 PM, メメメ wrote:
On Tue, 1 Jun 2010, vti wrote:
> And what does it do instead?
>
> And maybe you should also use chunked encoding for sending big files, so
> mojo will not hold it in memory.
How do I do that? I think that I need to make a callback which provides a
chunk at a time, but I'm not certain how to attach that to the route
handler in Mojolicious::Lite;
I think this from Mojo/HelloWorld.pm is likely relevant:
sub _chunked_params {
my ($self, $tx) = @_;
# Chunked
$tx->res->headers->transfer_encoding('chunked');
# Chunks
my $params = $tx->req->params->to_hash;
my $chunks = [];
for my $key (sort keys %$params) {
push @$chunks, $params->{$key};
}
# Callback
my $cb;
$cb = sub {
my $self = shift;
my $chunk = shift @$chunks || '';
$self->write_chunk($chunk, $chunk ? $cb : undef);
};
$cb->($tx->res);
$tx->resume;