X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst.pm;h=b7dd1794051820c129d07f56a5148c8de120e32d;hp=55aa48ae99eb41b03c312f346e80e36ffa511abc;hb=8d2fa70c6c45f97e181394e83ca19d0b9009703b;hpb=4dc24f349d31b9351f55e4e8e6c8aa07b91c3c20 diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 55aa48a..b7dd179 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -16,10 +16,21 @@ use Path::Class; 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/ ); @@ -45,7 +56,7 @@ our $DETACH = "catalyst_detach\n"; 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 @@ -56,7 +67,7 @@ __PACKAGE__->engine_class('Catalyst::Engine::CGI'); __PACKAGE__->request_class('Catalyst::Request'); __PACKAGE__->response_class('Catalyst::Response'); -our $VERSION = '5.54'; +our $VERSION = '5.57'; sub import { my ( $class, @arguments ) = @_; @@ -849,24 +860,6 @@ These methods are not meant to be used by end users. =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. @@ -946,22 +939,19 @@ sub execute { $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 = $@ ) { @@ -1025,11 +1015,7 @@ Finalizes cookies. =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 @@ -1072,8 +1058,6 @@ sub finalize_headers { $c->engine->finalize_headers( $c, @_ ); - bless $c->response->headers, "HTTP::Headers::ReadOnly"; - # Done $c->response->{_finalized_headers} = 1; } @@ -1137,8 +1121,9 @@ sub handle_request { }; 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 ) ); @@ -1781,9 +1766,6 @@ Writes $data to the output stream. When using this method directly, you will need to manually set the C 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 {