X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine%2FApache%2FMP20.pm;h=b20fea8a237734d3083405c8c1f795fc969f01ca;hb=2ef2fb0f3a712ba1239a5fed7e332ced3bbe663f;hp=74575e0f7f44bc56a36a92e2c0c040dbbb89c6fc;hpb=329a7e51e457b3cd30d88ddea13c596cff298d55;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine/Apache/MP20.pm b/lib/Catalyst/Engine/Apache/MP20.pm index 74575e0..b20fea8 100644 --- a/lib/Catalyst/Engine/Apache/MP20.pm +++ b/lib/Catalyst/Engine/Apache/MP20.pm @@ -1,20 +1,7 @@ package Catalyst::Engine::Apache::MP20; use strict; -use base 'Catalyst::Engine::Apache'; - -use Apache2::Connection (); -use Apache2::Const (); -use Apache2::RequestIO (); -use Apache2::RequestRec (); -use Apache2::RequestUtil (); -use Apache2::Request (); -use Apache2::Cookie (); -use Apache2::Upload (); -use Apache2::URI (); -use APR::URI (); - -Apache2::Const->import( -compile => ':common' ); +use base qw[Catalyst::Engine::Apache::MP20::Base Catalyst::Engine::CGI]; =head1 NAME @@ -30,83 +17,68 @@ This is the Catalyst engine specialized for Apache mod_perl version 2.0. =head1 OVERLOADED METHODS -This class overloads some methods from C. +This class overloads some methods from C +and C. =over 4 -=item $c->finalize_headers +=item $c->prepare_body =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; +sub prepare_body { + shift->Catalyst::Engine::CGI::prepare_body(@_); } -=item $c->handler +=item $c->prepare_parameters =cut -sub handler : method { - shift->SUPER::handler(@_); +sub prepare_parameters { + shift->Catalyst::Engine::CGI::prepare_parameters(@_); } -=item $c->prepare_request($r) +=item $c->prepare_request =cut sub prepare_request { - my ( $c, $r ) = @_; - $c->apache( Apache2::Request->new($r) ); -} + my ( $c, $r, @arguments ) = @_; -=item $c->prepare_uploads + unless ( $ENV{REQUEST_METHOD} ) { -=cut - -sub prepare_uploads { - my $c = shift; + $ENV{CONTENT_TYPE} = $r->headers_in->get("Content-Type"); + $ENV{CONTENT_LENGTH} = $r->headers_in->get("Content-Length"); + $ENV{QUERY_STRING} = $r->args; + $ENV{REQUEST_METHOD} = $r->method; - my @uploads; + my $cleanup = sub { + delete( $ENV{$_} ) for qw( CONTENT_TYPE + CONTENT_LENGTH + QUERY_STRING + REQUEST_METHOD ); + }; - for my $field ( $c->apache->upload ) { + $r->pool->cleanup_register($cleanup); + } - for my $upload ( $c->apache->upload($field) ) { + $c->SUPER::prepare_request($r); + $c->Catalyst::Engine::CGI::prepare_request( $r, @arguments ); +} - my $object = Catalyst::Request::Upload->new( - filename => $upload->filename, - size => $upload->size, - tempname => $upload->tempname, - type => $upload->type - ); +=item $c->prepare_uploads - push( @uploads, $field, $object ); - } - } +=cut - $c->req->_assign_values( $c->req->uploads, \@uploads ); +sub prepare_uploads { + shift->Catalyst::Engine::CGI::prepare_uploads(@_); } =back =head1 SEE ALSO -L, L, L. +L, L, L. =head1 AUTHOR