From: Christian Hansen Date: Tue, 17 May 2005 14:28:32 +0000 (+0000) Subject: Minor performance tweaks, added $c->request->user X-Git-Tag: 5.7099_04~1384 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=66294129a6520edc031aa7a43fc9bdfce669af15;hp=6890e59891b99d9b98973c9a37ca6022134e0ff5 Minor performance tweaks, added $c->request->user --- diff --git a/Changes b/Changes index 2e7455c..f50848f 100644 --- a/Changes +++ b/Changes @@ -2,7 +2,7 @@ This file documents the revision history for Perl extension Catalyst. 5.20 Sun Apr 24 17:00:00 2005 - improved uploads and parameters - - added $c->req->protocol and $c->req->secure + - added $c->req->protocol, $c->req->secure and $c->req->user - improved error message when forwarding to unknown module - fixed win32 installer - added deep recursion detection diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index 0aeefac..b0b84d9 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -623,35 +623,6 @@ Prepare uploads. sub prepare_uploads { } -=item $c->retrieve_components - -Retrieve Components. - -=cut - -sub retrieve_components { - my $self = shift; - - my $class = ref $self || $self; - eval <<""; - package $class; - import Module::Pluggable::Fast - name => '_components', - search => [ - '$class\::Controller', '$class\::C', - '$class\::Model', '$class\::M', - '$class\::View', '$class\::V' - ], - require => 1; - - if ( my $error = $@ ) { - chomp $error; - die qq/Couldn't load components "$error"/; - } - - return $self->_components; -} - =item $c->run Starts the engine. @@ -701,7 +672,7 @@ Setup components. sub setup_components { my $self = shift; - + # Components my $class = ref $self || $self; eval <<""; diff --git a/lib/Catalyst/Engine/Apache/Base.pm b/lib/Catalyst/Engine/Apache/Base.pm index bcf8458..d40f050 100644 --- a/lib/Catalyst/Engine/Apache/Base.pm +++ b/lib/Catalyst/Engine/Apache/Base.pm @@ -75,7 +75,8 @@ sub prepare_connection { $c->request->address( $c->apache->connection->remote_ip ); $c->request->hostname( $c->apache->connection->remote_host ); $c->request->protocol( $c->apache->protocol ); - + $c->request->user( $c->apache->user ); + if ( $ENV{HTTPS} || $c->apache->get_server_port == 443 ) { $c->request->secure(1); } diff --git a/lib/Catalyst/Engine/Apache/MP13/APR.pm b/lib/Catalyst/Engine/Apache/MP13/APR.pm index d978f9c..1867b1b 100644 --- a/lib/Catalyst/Engine/Apache/MP13/APR.pm +++ b/lib/Catalyst/Engine/Apache/MP13/APR.pm @@ -23,16 +23,6 @@ This class overloads some methods from C. =over 4 -=item $c->prepare_request($r) - -=cut - -sub prepare_request { - my ( $c, $r ) = @_; - $c->apache( Apache::Request->new($r) ); -} - - =item $c->prepare_parameters =cut @@ -51,6 +41,15 @@ sub prepare_parameters { $c->request->param(@params); } +=item $c->prepare_request($r) + +=cut + +sub prepare_request { + my ( $c, $r ) = @_; + $c->apache( Apache::Request->new($r) ); +} + =item $c->prepare_uploads =cut diff --git a/lib/Catalyst/Engine/CGI.pm b/lib/Catalyst/Engine/CGI.pm index 1a8f37c..409ce5a 100644 --- a/lib/Catalyst/Engine/CGI.pm +++ b/lib/Catalyst/Engine/CGI.pm @@ -5,6 +5,22 @@ use base 'Catalyst::Engine::CGI::Base'; use CGI; +our @compile = qw[ + delete + http + new_MultipartBuffer + param + parse_keywordlist + read_from_client + read_multipart + tmpFileName + uploadInfo + url_param + user_agent +]; + +CGI->compile(@compile); + __PACKAGE__->mk_accessors('cgi'); =head1 NAME @@ -29,15 +45,7 @@ appropriate engine module. =head1 DESCRIPTION This is the Catalyst engine specialized for the CGI environment (using the -C and C modules). Normally Catalyst will select the -appropriate engine according to the environment that it detects, however you -can force Catalyst to use the CGI engine by specifying the following in your -application module: - - use Catalyst qw(-Engine=CGI); - -The performance of this way of using Catalyst is not expected to be -useful in production applications, but it may be helpful for development. +C and C modules). =head1 METHODS diff --git a/lib/Catalyst/Engine/CGI/Base.pm b/lib/Catalyst/Engine/CGI/Base.pm index a76537b..8db3fe6 100644 --- a/lib/Catalyst/Engine/CGI/Base.pm +++ b/lib/Catalyst/Engine/CGI/Base.pm @@ -69,6 +69,7 @@ sub prepare_connection { $c->request->address( $ENV{REMOTE_ADDR} ); $c->request->hostname( $ENV{REMOTE_HOST} ); $c->request->protocol( $ENV{SERVER_PROTOCOL} ); + $c->request->user( $ENV{REMOTE_USER} ); if ( $ENV{HTTPS} || $ENV{SERVER_PORT} == 443 ) { $c->request->secure(1); diff --git a/lib/Catalyst/Request.pm b/lib/Catalyst/Request.pm index 8f96505..4e5ea1b 100644 --- a/lib/Catalyst/Request.pm +++ b/lib/Catalyst/Request.pm @@ -5,7 +5,7 @@ use base 'Class::Accessor::Fast'; __PACKAGE__->mk_accessors( qw/action address arguments body base cookies headers hostname match - method parameters path protocol secure snippets uploads/ + method parameters path protocol secure snippets uploads user/ ); *args = \&arguments; @@ -53,7 +53,8 @@ Catalyst::Request - Catalyst Request Class $req->snippets; $req->upload; $req->uploads; - $req->user_agent + $req->user; + $req->user_agent; See also L. @@ -308,6 +309,10 @@ hashref or a arrayref containing C objects. my $upload = $c->request->uploads->{field}; my $upload = $c->request->uploads->{field}->[0]; +=item $req->user + +Contains the user name of user if authentication check was successful. + =item $req->user_agent Shortcut to $req->headers->user_agent. User Agent version string.