Skip to content

Commit

Permalink
mention which methods need to load message content into memory to be …
Browse files Browse the repository at this point in the history
…able to parse it
  • Loading branch information
kraih committed May 31, 2013
1 parent 45aa2e4 commit 04ceeba
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Changes
@@ -1,4 +1,6 @@

4.10 2013-06-01

4.09 2013-05-31
- Updated jQuery to version 2.0.2.
- Increased default max_message_size from 5MB to 10MB in Mojo::Message.
Expand Down
14 changes: 11 additions & 3 deletions lib/Mojo/Message.pm
Expand Up @@ -431,6 +431,8 @@ C<POST> parameters extracted from C<x-application-urlencoded>,
C<application/x-www-form-urlencoded> or C<multipart/form-data> message body,
usually a L<Mojo::Parameters> object. Note that this method caches all data,
so it should not be called before the entire message body has been received.
Also note that message content needs to be loaded into memory to parse it, so
you have to make sure it is not excessively large.
# Get POST parameter value
say $msg->body_params->param('foo');
Expand Down Expand Up @@ -485,7 +487,9 @@ Access message cookies. Meant to be overloaded in a subclass.
Turns message body into a L<Mojo::DOM> object and takes an optional selector
to perform a C<find> on it right away, which returns a L<Mojo::Collection>
object. Note that this method caches all data, so it should not be called
before the entire message body has been received.
before the entire message body has been received. Also note that message
content needs to be loaded into memory to parse it, so you have to make sure
it is not excessively large.
# Perform "find" right away
say $msg->dom('h1, h2, h3')->pluck('text');
Expand Down Expand Up @@ -573,7 +577,9 @@ Check if message has exceeded C<max_line_size> or C<max_message_size>.
Decode JSON message body directly using L<Mojo::JSON> if possible, returns
C<undef> otherwise. An optional JSON Pointer can be used to extract a specific
value with L<Mojo::JSON::Pointer>. Note that this method caches all data, so
it should not be called before the entire message body has been received.
it should not be called before the entire message body has been received. Also
note that message content needs to be loaded into memory to parse it, so you
have to make sure it is not excessively large.
# Extract JSON values
say $msg->json->{foo}{bar}[23];
Expand All @@ -586,7 +592,9 @@ it should not be called before the entire message body has been received.
my @foo = $msg->param('foo');
Access C<POST> parameters. Note that this method caches all data, so it should
not be called before the entire message body has been received.
not be called before the entire message body has been received. Also note that
message content needs to be loaded into memory to parse it, so you have to
make sure it is not excessively large.
=head2 parse
Expand Down
6 changes: 5 additions & 1 deletion lib/Mojo/Message/Request.pm
Expand Up @@ -387,14 +387,18 @@ Check C<X-Requested-With> header for C<XMLHttpRequest> value.
Access C<GET> and C<POST> parameters. Note that this method caches all data,
so it should not be called before the entire request body has been received.
Also note that request content needs to be loaded into memory to parse it, so
you have to make sure it is not excessively large.
=head2 params
my $params = $req->params;
All C<GET> and C<POST> parameters, usually a L<Mojo::Parameters> object. Note
that this method caches all data, so it should not be called before the entire
request body has been received.
request body has been received. Also note that request content needs to be
loaded into memory to parse it, so you have to make sure it is not excessively
large.
# Get parameter value
say $req->params->param('foo');
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious.pm
Expand Up @@ -41,7 +41,7 @@ has static => sub { Mojolicious::Static->new };
has types => sub { Mojolicious::Types->new };

our $CODENAME = 'Top Hat';
our $VERSION = '4.09';
our $VERSION = '4.10';

sub AUTOLOAD {
my $self = shift;
Expand Down
4 changes: 3 additions & 1 deletion lib/Mojolicious/Controller.pm
Expand Up @@ -601,7 +601,9 @@ L<Mojo::Transaction::WebSocket> object.
Access GET/POST parameters, file uploads and route placeholder values that are
not reserved stash values. Note that this method is context sensitive in some
cases and therefore needs to be used with care, there can always be multiple
values, which might have unexpected consequences.
values, which might have unexpected consequences. Also note that request
content needs to be loaded into memory to parse it, so you have to make sure
it is not excessively large.
# List context is ambiguous and should be avoided
my $hash = {foo => $self->param('foo')};
Expand Down

0 comments on commit 04ceeba

Please sign in to comment.