X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst.pm;h=53cf38689e6fbe9ab2a4586b7512ca6de7471fca;hb=228f9466174380edff95b369034a04fd4b9cbb82;hp=6f1848a4db3502333a02f5e0e66faea5cf8f423e;hpb=85d9fce671016c9040775c8b4458cf9c72ec2208;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 6f1848a..53cf386 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -63,7 +63,7 @@ __PACKAGE__->response_class('Catalyst::Response'); # Remember to update this in Catalyst::Runtime as well! -our $VERSION = '5.7008'; +our $VERSION = '5.7011'; sub import { my ( $class, @arguments ) = @_; @@ -1353,7 +1353,7 @@ sub finalize { } if ($c->debug) { - my $elapsed = sprintf '%f', tv_interval($c->stats->getNodeValue); + my $elapsed = tv_interval($c->stats->getNodeValue); my $av = $elapsed == 0 ? '??' : sprintf '%.3f', 1 / $elapsed; my $t = Text::SimpleTable->new( [ 62, 'Action' ], [ 9, 'Time' ] ); @@ -1590,8 +1590,14 @@ sub prepare { $c->prepare_cookies; $c->prepare_path; - # On-demand parsing - $c->prepare_body unless $c->config->{parse_on_demand}; + # Prepare the body for reading, either by prepare_body + # or the user, if they are using $c->read + $c->prepare_read; + + # Parse the body unless the user wants it on-demand + unless ( $c->config->{parse_on_demand} ) { + $c->prepare_body; + } } my $method = $c->req->method || ''; @@ -1806,6 +1812,10 @@ C<$maxlength> defaults to the size of the request if not specified. You have to set C<< MyApp->config->{parse_on_demand} >> to use this directly. +Warning: If you use read(), Catalyst will not process the body, +so you will not be able to access POST parameters or file uploads via +$c->request. You must handle all body parsing yourself. + =cut sub read { my $c = shift; return $c->engine->read( $c, @_ ) } @@ -1862,6 +1872,11 @@ sub setup_components { my %comps = map { $_ => 1 } @comps; for my $component ( @comps ) { + + # We pass ignore_loaded here so that overlay files for (e.g.) + # Model::DBI::Schema sub-classes are loaded - if it's in @comps + # we know M::P::O found a file on disk so this is safe + Catalyst::Utils::ensure_class_loaded( $component, { ignore_loaded => 1 } ); my $module = $class->setup_component( $component ); @@ -2139,7 +2154,10 @@ the plugin name does not begin with C. my ( $proto, $plugin, $instant ) = @_; my $class = ref $proto || $proto; - Catalyst::Utils::ensure_class_loaded( $plugin, { ignore_loaded => 1 } ); + # no ignore_loaded here, the plugin may already have been + # defined in memory and we don't want to error on "no file" if so + + Catalyst::Utils::ensure_class_loaded( $plugin ); $proto->_plugins->{$plugin} = 1; unless ($instant) { @@ -2217,8 +2235,8 @@ This causes C to map to C. =head1 ON-DEMAND PARSER The request body is usually parsed at the beginning of a request, -but if you want to handle input yourself or speed things up a bit, -you can enable on-demand parsing with a config parameter. +but if you want to handle input yourself, you can enable on-demand +parsing with a config parameter. MyApp->config->{parse_on_demand} = 1; @@ -2363,6 +2381,8 @@ Sam Vilain Sascha Kiefer +Sebastian Willert + Tatsuhiko Miyagawa Ulf Edvinsson