Catalyst-Runtime
view release on metacpan or search on metacpan
5.7009 2007-08-22 00:14:00
- Moved Manual.pod to Manual.pm and clarified status of
Catalyst-Manual dist
- Doc patches to Catalyst::Controller
- remove ignore_loaded from plugin load, commenting why
- document the ignore_loaded feature in Catalyst::Utils
- Add testing of inline plugins.
5.7008 2007-08-13 08:40:00
- Added $c->request->query_keywords for getting the keywords
(a query string with no parameters).
- Add undef warning for uri_for.
- Fix bug where a nested component would be setup twice.
- Make ensure_class_loaded behave better with malformed class name.
- Make _register_plugin use ensure_class_loaded.
- Remove 'Argument "??" isn't numeric in sprintf' warning.
(Emanuele Zeppieri)
- Fixed a bug where Content-Length could be set to 0 if a filehandle
object in $c->response->body did not report a size.
- Fixed issue where development server running in fork mode did not
t/optional_stress.t
t/optional_threads.t
t/path_action_empty_brackets.t
t/plack-middleware-plugin.t
t/plack-middleware.t
t/plugin_new_method_backcompat.t
t/psgi-log.t
t/psgi_file_testapp.t
t/psgi_utils.t
t/query_constraints.t
t/query_keywords_and_parameters.t
t/relative_root_action_for_bug.t
t/remove_redundant_body.t
t/set_allowed_method.t
t/something/Makefile.PL
t/something/script/foo/bar/for_dist
t/state.t
t/undef-params.t
t/undef_encoding_regression.t
t/unicode-exception-bug.t
t/unicode-exception-return-value.t
lib/Catalyst.pm view on Meta::CPAN
}
=head2 $c->log_request
Writes information about the request to the debug logs. This includes:
=over 4
=item * Request method, path, and remote IP address
=item * Query keywords (see L<Catalyst::Request/query_keywords>)
=item * Request parameters
=item * File uploads
=back
=cut
sub log_request {
lib/Catalyst.pm view on Meta::CPAN
$path = '/' unless length $path;
$address ||= '';
$path =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
$path = decode_utf8($path);
$c->log->debug(qq/"$method" request for "$path" from "$address"/);
$c->log_request_headers($request->headers);
if ( my $keywords = $request->query_keywords ) {
$c->log->debug("Query keywords are: $keywords");
}
$c->log_request_parameters( query => $request->query_parameters, $request->_has_body ? (body => $request->body_parameters) : () );
$c->log_request_uploads($request);
}
=head2 $c->log_response
lib/Catalyst/Engine.pm view on Meta::CPAN
my $is_first_pair = 1;
for my $pair (@unsplit_pairs) {
my ($name, $value)
= map { defined $_ ? $decoder->($self->unescape_uri($_)) : $_ }
( split /=/, $pair, 2 )[0,1]; # slice forces two elements
if ($is_first_pair) {
# If the first pair has no equal sign, then it means the isindex
# flag is set.
$c->request->query_keywords($name) unless defined $value;
$is_first_pair = 0;
}
$p->add( $name => $value );
}
$c->encoding($old_encoding) if $old_encoding;
$c->request->query_parameters( $c->request->_use_hash_multivalue ? $p : $p->mixed );
lib/Catalyst/Request.pm view on Meta::CPAN
sub prepare_cookies {
my ( $self ) = @_;
if ( my $header = $self->header('Cookie') ) {
return { CGI::Simple::Cookie->parse($header) };
}
{};
}
has query_keywords => (is => 'rw');
has match => (is => 'rw');
has method => (is => 'rw');
has protocol => (is => 'rw');
has query_parameters => (is => 'rw', lazy=>1, default => sub { shift->_use_hash_multivalue ? Hash::MultiValue->new : +{} });
has secure => (is => 'rw', default => 0);
has captures => (is => 'rw', default => sub { [] });
has uri => (is => 'rw', predicate => 'has_uri');
has remote_user => (is => 'rw');
has headers => (
is => 'rw',
lib/Catalyst/Request.pm view on Meta::CPAN
$req->body_parameters;
$req->content_encoding;
$req->content_length;
$req->content_type;
$req->cookie;
$req->cookies;
$req->header;
$req->headers;
$req->hostname;
$req->input;
$req->query_keywords;
$req->match;
$req->method;
$req->param;
$req->parameters;
$req->params;
$req->path;
$req->protocol;
$req->query_parameters;
$req->read;
$req->referer;
lib/Catalyst/Request.pm view on Meta::CPAN
print $c->request->headers->header('X-Catalyst');
=head2 $req->hostname
Returns the hostname of the client. Use C<< $req->uri->host >> to get the hostname of the server.
=head2 $req->input
Alias for $req->body.
=head2 $req->query_keywords
Contains the keywords portion of a query string, when no '=' signs are
present.
http://localhost/path?some+keywords
$c->request->query_keywords will contain 'some keywords'
=head2 $req->match
This contains the matching part of a Regex action. Otherwise
it returns the same as 'action', except for default actions,
which return an empty string.
=head2 $req->method
Contains the request method (C<GET>, C<POST>, C<HEAD>, etc).
t/aggregate/live_engine_request_parameters.t view on Meta::CPAN
my $request = POST(
'http://localhost/dump/request/a/b?query+string',
'Content' => $body_parameters,
'Content-Type' => 'application/x-www-form-urlencoded'
);
ok( my $response = request($request), 'Request' );
ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' );
is( $creq->uri->query, 'query+string', 'Catalyst::Request POST query_string' );
is( $creq->query_keywords, 'query string', 'Catalyst::Request query_keywords' );
is_deeply( $creq->query_parameters, $query_parameters, 'Catalyst::Request query_parameters' );
is_deeply( $creq->body_parameters, $body_parameters, 'Catalyst::Request body_parameters' );
is_deeply( $creq->parameters, $parameters, 'Catalyst::Request parameters' );
ok( $response = request('http://localhost/dump/request/a/b?x=1&y=1&z=1'), 'Request' );
ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' );
is( $creq->uri->query, 'x=1&y=1&z=1', 'Catalyst::Request GET query_string' );
}
{
t/query_keywords_and_parameters.t view on Meta::CPAN
# These tests assume that the decoding that occurs for the query string follows
# the payload decoding algorithm described here:
# https://www.w3.org/TR/html5/forms.html#url-encoded-form-data
{
ok my $req = GET 'root/bar';
my ($res, $c) = ctx_request($req);
ok !defined($c->req->query_keywords), 'query_keywords is not defined when no ?';
is_deeply $c->req->query_parameters, {}, 'query_parameters defined, but empty for no ?';
}
{
ok my $req = GET 'root/bar?';
my ($res, $c) = ctx_request($req);
ok !defined $c->req->query_keywords, 'query_keywords is not defined when ? with empty query string';
is_deeply $c->req->query_parameters, {}, 'query_parameters defined, but empty with empty query string';
}
{
ok my $req = GET 'root/bar?a=b';
my ($res, $c) = ctx_request($req);
ok !defined($c->req->query_keywords), 'query_keywords undefined when isindex not set';
is_deeply $c->req->query_parameters, { a => 'b' }, 'query_parameters defined for ?a=b';
}
{
ok my $req = GET 'root/bar?x';
my ($res, $c) = ctx_request($req);
is $c->req->query_keywords, 'x', 'query_keywords defined for ?x';
# The algorithm reads like 'x' should be treated as a value, not a name.
# Perl does not support undef as a hash key. I feel this would be the best
# alternative as isindex is moving towards complete deprecation.
is_deeply $c->req->query_parameters, { 'x' => undef }, 'query_parameters defined for ?x';
}
{
ok my $req = GET 'root/bar?x&a=b';
my ($res, $c) = ctx_request($req);
is $c->req->query_keywords, 'x', 'query_keywords defined for ?x&a=b';
# See comment above about the 'query_parameters defined for ?x' test case.
is_deeply $c->req->query_parameters, { 'x' => undef, a => 'b' }, 'query_parameters defined for ?x&a=b';
}
done_testing();
t/utf_incoming.t view on Meta::CPAN
is $c->req->body_parameters->{a}, 1;
is $res->content_charset, 'UTF-8';
}
{
my ($res, $c) = ctx_request GET "/base/â¥?â¥â¥â¥";
is $res->code, 200, 'OK';
is decode_utf8($res->content), '<p>This is base-link action â¥</p>', 'correct body';
is $res->content_length, 35, 'correct length';
is $c->req->query_keywords, 'â¥â¥â¥';
is $res->content_charset, 'UTF-8';
}
{
my $res = request "/base/â¥/â¥";
is $res->code, 200, 'OK';
is decode_utf8($res->content), '<p>This is base-link action ⥠â¥</p>', 'correct body';
is $res->content_length, 39, 'correct length';
is $res->content_charset, 'UTF-8';
( run in 1.816 second using v1.01-cache-2.11-cpan-299005ec8e3 )