From: Sebastian Riedel Date: Fri, 15 Apr 2005 20:26:16 +0000 (+0000) Subject: Added MP20 X-Git-Tag: 5.7099_04~1514 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=300aea89a003c0e6a78ef63c47078fa346556f82 Added MP20 --- diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 5bc4546..6e82dcc 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -156,7 +156,10 @@ sub import { require mod_perl; - if ( $mod_perl::VERSION >= 1.99 ) { + if ( $mod_perl::VERSION >= 1.999.22 ) { + $engine = 'Catalyst::Engine::Apache::MP20'; + } + elsif ( $mod_perl::VERSION >= 1.99 ) { $engine = 'Catalyst::Engine::Apache::MP19'; } else { @@ -164,12 +167,14 @@ sub import { } } - $caller->log->info("You are running an old helper script! ". - "Please update your scripts by regenerating the ". - "application and copying over the new scripts.") - if ( $ENV{CATALYST_SCRIPT_GEN} && ( - $ENV{CATALYST_SCRIPT_GEN} < - $Catalyst::Helper::CATALYST_SCRIPT_GEN )) ; + $caller->log->info( "You are running an old helper script! " + . "Please update your scripts by regenerating the " + . "application and copying over the new scripts." ) + if ( $ENV{CATALYST_SCRIPT_GEN} + && ( + $ENV{CATALYST_SCRIPT_GEN} < $Catalyst::Helper::CATALYST_SCRIPT_GEN ) + ); + # Process options my @plugins; foreach (@options) { diff --git a/lib/Catalyst/Engine/Apache/MP20.pm b/lib/Catalyst/Engine/Apache/MP20.pm new file mode 100644 index 0000000..8f89ff1 --- /dev/null +++ b/lib/Catalyst/Engine/Apache/MP20.pm @@ -0,0 +1,114 @@ +package Catalyst::Engine::Apache::MP20; + +use strict; +use base 'Catalyst::Engine::Apache'; + +use Apache2 (); +use Apache2::Connection (); +use Apache2::Const (); +use Apache2::RequestIO (); +use Apache2::RequestRec (); +use Apache2::RequestUtil (); +use Apache::Request (); +use Apache::Cookie (); +use Apache::Upload (); +use Apache2::URI (); +use APR::URI (); + +Apache2::Const->import( -compile => ':common' ); + +=head1 NAME + +Catalyst::Engine::Apache::MP20 - Catalyst Apache MP20 Engine + +=head1 SYNOPSIS + +See L. + +=head1 DESCRIPTION + +This is the Catalyst engine specialized for Apache mod_perl version 2. + +=head1 OVERLOADED METHODS + +This class overloads some methods from C. + +=over 4 + +=item $c->finalize_headers + +=cut + +sub finalize_headers { + my $c = shift; + + for my $name ( $c->response->headers->header_field_names ) { + next if $name =~ /Content-Type/i; + my @values = $c->response->header($name); + $c->apache->headers_out->add( $name => $_ ) for @values; + } + + if ( $c->response->header('Set-Cookie') && $c->response->status >= 300 ) { + my @values = $c->response->header('Set-Cookie'); + $c->apache->err_headers_out->add( 'Set-Cookie' => $_ ) for @values; + } + + $c->apache->status( $c->response->status ); + $c->apache->content_type( $c->response->header('Content-Type') ); + + return 0; +} + +=item $c->handler + +=cut + +sub handler : method { + shift->SUPER::handler(@_); +} + +=item $c->prepare_uploads + +=cut + +sub prepare_uploads { + my $c = shift; + + my @uploads; + + for my $field ( $c->apache->upload ) { + + for my $upload ( $c->apache->upload($field) ) { + + my $object = Catalyst::Request::Upload->new( + filename => $upload->filename, + size => $upload->size, + tempname => $upload->tempname, + type => $upload->type + ); + + push( @uploads, $field, $object ); + } + } + + $c->req->_assign_values( $c->req->uploads, \@uploads ); +} + +=back + +=head1 SEE ALSO + +L, L, L. + +=head1 AUTHOR + +Sebastian Riedel, C + +=head1 COPYRIGHT + +This program is free software, you can redistribute it and/or modify it under +the same terms as Perl itself. + +=cut + +1;