use Time::HiRes qw/gettimeofday tv_interval/;
use URI;
use Scalar::Util qw/weaken/;
-use Hash::Util qw/lock_hash/;
-use HTTP::Headers::ReadOnly;
use attributes;
+# For PAR
+require Catalyst::Helper;
+require Catalyst::PAR;
+require Catalyst::Build;
+require Catalyst::Test;
+
+require Catalyst::Engine::HTTP;
+require Catalyst::Engine::CGI;
+
+require Catalyst::Controller;
+require Catalyst::Model;
+require Catalyst::View;
+
__PACKAGE__->mk_accessors(
qw/counter request response state action stack namespace/
);
require Module::Pluggable::Fast;
# Helper script generation
-our $CATALYST_SCRIPT_GEN = 11;
+our $CATALYST_SCRIPT_GEN = 18;
__PACKAGE__->mk_classdata($_)
for qw/components arguments dispatcher engine log dispatcher_class
__PACKAGE__->request_class('Catalyst::Request');
__PACKAGE__->response_class('Catalyst::Response');
-our $VERSION = '5.52';
+our $VERSION = '5.57';
sub import {
my ( $class, @arguments ) = @_;
=item $c->error($arrayref)
-Returns an arrayref containing error messages.
+Returns an arrayref containing error messages. If Catalyst encounters an
+error while processing a request, it stores the error in $c->error. This
+method should not be used to store non-fatal error messages.
my @error = @{ $c->error };
$c->error('Something bad happened');
-Clear errors.
+Clear errors. You probably don't want to clear the errors unless you are
+implementing a custom error screen.
$c->error(0);
<<"EOF") if ( $ENV{CATALYST_SCRIPT_GEN} && ( $ENV{CATALYST_SCRIPT_GEN} < $Catalyst::CATALYST_SCRIPT_GEN ) );
You are running an old script!
- Please update by running:
- catalyst.pl -nonew -scripts $class
+ Please update by running (this will overwrite existing files):
+ catalyst.pl -force -scripts $class
+
+ or (this will not overwrite existing files):
+ catalyst.pl -scripts $class
EOF
if ( $class->debug ) {
=over 4
-=item $c->benchmark( $coderef )
-
-Takes a coderef with arguments and returns elapsed time as float.
-
- my ( $elapsed, $status ) = $c->benchmark( sub { return 1 } );
- $c->log->info( sprintf "Processing took %f seconds", $elapsed );
-
-=cut
-
-sub benchmark {
- my $c = shift;
- my $code = shift;
- my $time = [gettimeofday];
- my @return = &$code(@_);
- my $elapsed = tv_interval $time;
- return wantarray ? ( $elapsed, @return ) : $elapsed;
-}
-
=item $c->components
Returns a hash of components.
$action = "-> $action" if $callsub =~ /forward$/;
}
push( @{ $c->stack }, $code );
- eval {
- if ( $c->debug )
+ my $elapsed = 0;
+ my $start = 0;
+ $start = [gettimeofday] if $c->debug;
+ eval { $c->state( &$code( $class, $c, @{ $c->req->args } ) || 0 ) };
+ $elapsed = tv_interval($start) if $c->debug;
+
+ if ( $c->debug ) {
+ unless ( ( $code->name =~ /^_.*/ )
+ && ( !$c->config->{show_internal_actions} ) )
{
- my ( $elapsed, @state ) =
- $c->benchmark( $code, $class, $c, @{ $c->req->args } );
- unless ( ( $code->name =~ /^_.*/ )
- && ( !$c->config->{show_internal_actions} ) )
- {
- push @{ $c->{stats} }, [ $action, sprintf( '%fs', $elapsed ) ];
- }
- $c->state(@state);
- }
- else {
- $c->state( &$code( $class, $c, @{ $c->req->args } ) || 0 );
+ push @{ $c->{stats} }, [ $action, sprintf( '%fs', $elapsed ) ];
}
- };
+ }
pop( @{ $c->stack } );
if ( my $error = $@ ) {
=cut
-sub finalize_cookies {
- my $c = shift;
- $c->engine->finalize_cookies( $c, @_ );
- lock_hash( %$_ ) for $c->res->cookies, values %{ $c->res->cookies };
-}
+sub finalize_cookies { my $c = shift; $c->engine->finalize_cookies( $c, @_ ) }
=item $c->finalize_error
$c->engine->finalize_headers( $c, @_ );
- bless $c->response->headers, "HTTP::Headers::ReadOnly";
-
# Done
$c->response->{_finalized_headers} = 1;
}
};
if ( $class->debug ) {
- my $elapsed;
- ( $elapsed, $status ) = $class->benchmark($handler);
+ my $start = [gettimeofday];
+ $status = &$handler;
+ my $elapsed = tv_interval $start;
$elapsed = sprintf '%f', $elapsed;
my $av = sprintf '%.3f',
( $elapsed == 0 ? '??' : ( 1 / $elapsed ) );
return $instance;
};
- eval {
- Module::Pluggable::Fast->import(
+ eval "package $class;\n" . q!Module::Pluggable::Fast->import(
name => '_catalyst_components',
search => [
"$class\::Controller", "$class\::C",
],
callback => $callback
);
- };
+ !;
if ( my $error = $@ ) {
will need to manually set the C<Content-Length> header to the length of
your output data, if known.
-Also note that any headers created after the write can no longer be added, and
-this includes cookies.
-
=cut
sub write {
David Naughton
+Drew Taylor
+
Gary Ashton Jones
Geoff Richards