Skip to content

Commit

Permalink
be more specific about POST parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jul 29, 2014
1 parent f3ba3e1 commit 30b2723
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 30 deletions.
11 changes: 6 additions & 5 deletions lib/Mojo/Message.pm
Expand Up @@ -585,11 +585,12 @@ sure it is not excessively large, there's a 10MB limit by default.
my @foo = $msg->param('foo');
my ($foo, $bar) = $msg->param(['foo', 'bar']);
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. Parts of the
message body need to be loaded into memory to parse C<POST> parameters, so you
have to make sure it is not excessively large, there's a 10MB limit by
default.
Access C<POST> parameters extracted from C<application/x-www-form-urlencoded>
or C<multipart/form-data> message body. Note that this method caches all data,
so it should not be called before the entire message body has been received.
Parts of the message body need to be loaded into memory to parse C<POST>
parameters, so you have to make sure it is not excessively large, there's a
10MB limit by default.
=head2 parse
Expand Down
23 changes: 13 additions & 10 deletions lib/Mojo/Message/Request.pm
Expand Up @@ -400,21 +400,24 @@ Check C<X-Requested-With> header for C<XMLHttpRequest> value.
my @foo = $req->param('foo');
my ($foo, $bar) = $req->param(['foo', 'bar']);
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.
Parts of the request body need to be loaded into memory to parse C<POST>
parameters, so you have to make sure it is not excessively large, there's a
10MB limit by default.
Access C<GET> and C<POST> parameters extracted from
C<application/x-www-form-urlencoded> or C<multipart/form-data> message body.
Note that this method caches all data, so it should not be called before the
entire request body has been received. Parts of the request body need to be
loaded into memory to parse C<POST> parameters, so you have to make sure it is
not excessively large, there's a 10MB limit by default.
=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. Parts of the request body need to be loaded
into memory to parse C<POST> parameters, so you have to make sure it is not
excessively large, there's a 10MB limit by default.
All C<GET> and C<POST> parameters extracted from
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 request body has been received.
Parts of the request body need to be loaded into memory to parse C<POST>
parameters, so you have to make sure it is not excessively large, there's a
10MB limit by default.
# Get parameter value
say $req->params->param('foo');
Expand Down
21 changes: 12 additions & 9 deletions lib/Mojolicious/Controller.pm
Expand Up @@ -598,12 +598,13 @@ status.
$c = $c->param(foo => ['ba;r', 'baz']);
Access route placeholder values that are not reserved stash values, file
uploads and C<GET>/C<POST> parameters, in that order. 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.
Parts of the request body need to be loaded into memory to parse C<POST>
parameters, so you have to make sure it is not excessively large, there's a
10MB limit by default.
uploads as well as C<GET> and C<POST> parameters extracted from
C<application/x-www-form-urlencoded> or C<multipart/form-data> message body,
in that order. 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. Parts of the request body need to be
loaded into memory to parse C<POST> parameters, so you have to make sure it is
not excessively large, there's a 10MB limit by default.
# List context is ambiguous and should be avoided, you can get multiple
# values returned for a query string like "?foo=bar&foo=baz&foo=yada"
Expand Down Expand Up @@ -945,9 +946,11 @@ to inherit query parameters from the current request.
my $validation = $c->validation;
Get L<Mojolicious::Validator::Validation> object for current request to
validate C<GET>/C<POST> parameters. Parts of the request body need to be
loaded into memory to parse C<POST> parameters, so you have to make sure it is
not excessively large, there's a 10MB limit by default.
validate C<GET> and C<POST> parameters extracted from
C<application/x-www-form-urlencoded> or C<multipart/form-data> message body.
Parts of the request body need to be loaded into memory to parse C<POST>
parameters, so you have to make sure it is not excessively large, there's a
10MB limit by default.
my $validation = $c->validation;
$validation->required('title')->size(3, 50);
Expand Down
12 changes: 6 additions & 6 deletions lib/Mojolicious/Guides/Rendering.pod
Expand Up @@ -669,12 +669,12 @@ This chain could go on and on to allow a very high level of template reuse.

=head2 Form validation

You can use L<Mojolicious::Controller/"validation"> to validate C<GET>/C<POST>
parameters submitted to your application. All unknown fields will be ignored
by default, so you have to decide which should be required or optional before
you can perform checks on their values. Every check is performed right away,
so you can use the results immediately to build more advanced validation logic
with methods like L<Mojolicious::Validator::Validation/"is_valid">.
You can use L<Mojolicious::Controller/"validation"> to validate C<GET> and
C<POST> parameters submitted to your application. All unknown fields will be
ignored by default, so you have to decide which should be required or optional
before you can perform checks on their values. Every check is performed right
away, so you can use the results immediately to build more advanced validation
logic with methods like L<Mojolicious::Validator::Validation/"is_valid">.

use Mojolicious::Lite;

Expand Down

0 comments on commit 30b2723

Please sign in to comment.