Skip to content

Commit

Permalink
recommend max_response_size instead of max_message_size
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 28, 2017
1 parent cebedc8 commit d064ea2
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions lib/Mojolicious/Guides/Cookbook.pod
Expand Up @@ -1119,13 +1119,9 @@ file with L<Mojo::Asset::File/"move_to">.
my $tx = $ua->get('https://www.github.com/kraih/mojo/tarball/master');
$tx->res->content->asset->move_to('mojo.tar.gz');

To protect you from excessively large files there is also a limit of 16MB by
To protect you from excessively large files there is also a limit of 2GB by
default, which you can tweak with the attribute
L<Mojo::Message/"max_message_size"> or C<MOJO_MAX_MESSAGE_SIZE> environment
variable.

# Increase limit to 1GB
$ENV{MOJO_MAX_MESSAGE_SIZE} = 1073741824;
L<Mojo::UserAgent/"max_response_size">.

=head2 Large file upload

Expand All @@ -1148,13 +1144,12 @@ L<Mojo::UserAgent> makes it actually easy.

use Mojo::UserAgent;

# Accept responses of indefinite size
my $ua = Mojo::UserAgent->new(max_response_size => 0);

# Build a normal transaction
my $ua = Mojo::UserAgent->new;
my $tx = $ua->build_tx(GET => 'http://example.com');

# Accept response of indefinite size
$tx->res->max_message_size(0);

# Replace "read" events to disable default content parser
$tx->res->content->unsubscribe('read')->on(read => sub {
my ($content, $bytes) = @_;
Expand Down

0 comments on commit d064ea2

Please sign in to comment.