Mojo::UserAgent download largest file doesn't work

227 views
Skip to first unread message

Peng Li

unread,
May 25, 2016, 1:27:14 PM5/25/16
to Mojolicious

Hi,

I just learn the mojo framework, it's a good web framework.

but when I test the example on the website, I test this example
http://mojolicious.org/perldoc/Mojolicious/Guides/Cookbook#Large-file-downloads

use Mojo::UserAgent;

# Fetch the latest Mojolicious tarball
my $ua = Mojo::UserAgent->new(max_redirects => 5);
my $tx = $ua->get('https://www.github.com/kraih/mojo/tarball/master');
$tx->res->content->asset->move_to('mojo.tar.gz');

this code doesn't work for me, it indeed generate a new file mojo.tar.gz, but the size is 0B. 
While I tried changing the url into some others file, it works.
 Also I tried using the command 'wget https://www.github.com/kraih/mojo/tarball/master -p mojo.tar.gz' on mac, it can download the mojo tarball.

I don't know why the code snippet above doesn't work for the mojo tarball.

Thanks,
Peng

Stefan Adams

unread,
May 25, 2016, 1:40:09 PM5/25/16
to mojolicious
Perhaps you need to increase the MAX_MESSAGE_SIZE?

$ENV{MOJO_MAX_MESSAGE_SIZE} = 1073741824;

--
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious...@googlegroups.com.
To post to this group, send email to mojol...@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Peng Li

unread,
May 25, 2016, 9:30:07 PM5/25/16
to Mojolicious
Yes, I set this environment variable, it still doesn't work, the size of downloaded mojo.tar.gz still 0B

Brian Manning

unread,
May 26, 2016, 10:05:32 AM5/26/16
to Mojolicious


On Wednesday, May 25, 2016 at 10:27:14 AM UTC-7, Peng Li wrote:
but when I test the example on the website, I test this example
http://mojolicious.org/perldoc/Mojolicious/Guides/Cookbook#Large-file-downloads

use Mojo::UserAgent;

# Fetch the latest Mojolicious tarball
my $ua = Mojo::UserAgent->new(max_redirects => 5);
my $tx = $ua->get('https://www.github.com/kraih/mojo/tarball/master');
$tx->res->content->asset->move_to('mojo.tar.gz');

this code doesn't work for me, it indeed generate a new file mojo.tar.gz, but the size is 0B.

This code worked fine for me; the downloaded tarball size is 651k, so no problems with the default MOJO_MAX_MESSAGE_SIZE.

Maybe you have permissions and/or network issues on your host that's preventing you from writing the file?  The Mojo::UserAgent example [1] shows how to query $tx to see if an error was returned from your request; I would suggest seeing if an error was returned, and if so, what the error is.

My environment:

OS X Yosemite 10.10.5
Perl version: 5.22.1
Mojolicious version: 6.58

Thanks,

Brian

Peng Li

unread,
May 26, 2016, 10:21:52 PM5/26/16
to mojol...@googlegroups.com
Thanks very much Brain,

as your suggestion, I print out the $tx error, yes, the $tx->success is indeed false, and the error message is

IO::Socket::SSL 1.94+ required for TLS support

After google it, I find the solution in this page  http://yaskevich.com/mojo-useragent-fails-on-https-connection

just run cpan IO::Socket::SSL ,

Now the code  can works for me.  Thanks for your help.


Thanks,
Peng

--
You received this message because you are subscribed to a topic in the Google Groups "Mojolicious" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mojolicious/KE7a6-4kyRg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mojolicious...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages