X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine%2FCGI.pm;h=409ce5a87a75ca667861a431dd780b7760bebdd0;hb=66294129a6520edc031aa7a43fc9bdfce669af15;hp=9305c1be9667f9f28e1b1cc6fec8b3a3e498912c;hpb=c2e8e6fa308480a083f88f9fd82f835aae150c34;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine/CGI.pm b/lib/Catalyst/Engine/CGI.pm index 9305c1b..409ce5a 100644 --- a/lib/Catalyst/Engine/CGI.pm +++ b/lib/Catalyst/Engine/CGI.pm @@ -5,6 +5,24 @@ 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 Catalyst::Engine::CGI - The CGI Engine @@ -27,15 +45,17 @@ 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: +C and C modules). + +=head1 METHODS + +=over 4 + +=item $c->cgi - use Catalyst qw(-Engine=CGI); +Contains the C object. -The performance of this way of using Catalyst is not expected to be -useful in production applications, but it may be helpful for development. +=back =head1 OVERLOADED METHODS @@ -88,9 +108,35 @@ sub prepare_parameters { =cut sub prepare_request { - my ( $c, $cgi ) = @_; + my ( $c, $object ) = @_; + + my $cgi; + + if ( defined($object) && ref($object) ) { + + if ( $object->isa('Apache') ) { # MP 1.3 + $cgi = CGI->new($object); + } + + elsif ( $object->isa('Apache::RequestRec') ) { # MP 1.99 + $cgi = CGI->new($object); + } + + elsif ( $object->isa('Apache2::RequestRec') ) { # MP 2.00 + $cgi = CGI->new($object); + } + + elsif ( $object->isa('CGI') ) { + $cgi = $object; + } + + else { + my $class = ref($object); + die( qq/Invalid argument $object/ ); + } + } + $c->cgi( $cgi || CGI->new ); - $c->cgi->_reset_globals; } =item $c->prepare_uploads