X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FEngine%2FApache.pm;h=2e0f374c8f65a6b07dd687f911f2b7c4d97005a3;hp=3259c3bfeb017082894749e9ad59aa0a8e18eb71;hb=21465c884872c1ec8c30acd72796445f9eaacb31;hpb=bc146cf406f4e6c188e63f0206de220fab56fb2a diff --git a/lib/Catalyst/Engine/Apache.pm b/lib/Catalyst/Engine/Apache.pm index 3259c3b..2e0f374 100644 --- a/lib/Catalyst/Engine/Apache.pm +++ b/lib/Catalyst/Engine/Apache.pm @@ -1,13 +1,24 @@ package Catalyst::Engine::Apache; use strict; -use mod_perl; -use constant MP2 => $mod_perl::VERSION >= 1.99; -use base 'Catalyst::Engine'; -use URI; -use URI::http; -__PACKAGE__->mk_accessors(qw/apache/); +# 1.27 MP13 +# 1.28 MP13 +# 1.29 MP13 +# 1.2901 MP13 +# 1.30 MP13 TBR + +# 1.9901 MP19 +# 1.9920 MP19 +# 1.999020 MP19 RC3 +# 1.999021 MP19 RC4 + +# 1.999022 MP20 RC5 +# 1.999023 MP20 RC6 + +1; + +__END__ =head1 NAME @@ -19,148 +30,7 @@ See L. =head1 DESCRIPTION -This is the Catalyst engine specialized for Apache (i.e. for mod_perl). - -=head1 METHODS - -=over 4 - -=item $c->apache - -Returns an C object. - -=back - -=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') ); - - unless ( MP2 ) { - $c->apache->send_http_header; - } - - return 0; -} - -=item $c->finalize_output - -=cut - -sub finalize_output { - my $c = shift; - $c->apache->print( $c->response->output ); -} - -=item $c->prepare_connection - -=cut - -sub prepare_connection { - my $c = shift; - $c->request->hostname( $c->apache->connection->remote_host ); - $c->request->address( $c->apache->connection->remote_ip ); -} - -=item $c->prepare_headers - -=cut - -sub prepare_headers { - my $c = shift; - $c->request->method( $c->apache->method ); - $c->request->header( %{ $c->apache->headers_in } ); -} - -=item $c->prepare_parameters - -=cut - -sub prepare_parameters { - my $c = shift; - my %args; - foreach my $key ( $c->apache->param ) { - my @values = $c->apache->param($key); - $args{$key} = @values == 1 ? $values[0] : \@values; - } - $c->request->parameters( \%args ); -} - -=item $c->prepare_path - -=cut - -# XXX needs fixing, only work with directive, -# not directive -sub prepare_path { - my $c = shift; - $c->request->path( $c->apache->uri ); - my $loc = $c->apache->location; - no warnings 'uninitialized'; - $c->req->{path} =~ s/^($loc)?\///; - my $base = URI->new; - $base->scheme( $ENV{HTTPS} ? 'https' : 'http' ); - $base->host( $c->apache->hostname ); - $base->port( $c->apache->get_server_port ); - my $path = $c->apache->location; - $base->path( $path =~ /\/$/ ? $path : "$path/" ); - $c->request->base( $base->as_string ); -} - -=item $c->prepare_request($r) - -=cut - -sub prepare_request { - my ( $c, $r ) = @_; - $c->apache( Apache::Request->new($r) ); -} - -=item $c->prepare_uploads - -=cut - -sub prepare_uploads { - my $c = shift; - for my $upload ( $c->apache->upload ) { - $upload = $c->apache->upload($upload) if MP2; - $c->request->uploads->{ $upload->filename } = { - fh => $upload->fh, - size => $upload->size, - type => $upload->type - }; - } -} - -=item $c->run - -=cut - -sub run { } - -=back +This class will load the correct MP Engine. =head1 SEE ALSO @@ -169,6 +39,7 @@ L. =head1 AUTHOR Sebastian Riedel, C +Christian Hansen C =head1 COPYRIGHT @@ -176,5 +47,3 @@ This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut - -1;