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=55d8e89a14bd3eeb32aea14f5505012e93ff1407;hb=21465c884872c1ec8c30acd72796445f9eaacb31;hpb=23f9d93414eadb11350029f13b51841d8309363b diff --git a/lib/Catalyst/Engine/Apache.pm b/lib/Catalyst/Engine/Apache.pm index 55d8e89..2e0f374 100644 --- a/lib/Catalyst/Engine/Apache.pm +++ b/lib/Catalyst/Engine/Apache.pm @@ -1,183 +1,36 @@ package Catalyst::Engine::Apache; use strict; -use mod_perl; -use constant MP2 => $mod_perl::VERSION >= 1.99; -use base 'Catalyst::Engine'; -use URI; - -# mod_perl -if (MP2) { - require Apache2; - require Apache::RequestIO; - require Apache::RequestRec; - require Apache::SubRequest; - require Apache::RequestUtil; - require APR::URI; - require Apache::URI; -} -else { require Apache } - -# libapreq -require Apache::Request; -require Apache::Cookie; -require Apache::Upload if MP2; - -__PACKAGE__->mk_accessors(qw/apache_request original_request/); -=head1 NAME - -Catalyst::Engine::Apache - Catalyst Apache Engine - -=head1 SYNOPSIS - -See L. - -=head1 DESCRIPTION - -This is the Catalyst engine specialized for Apache (i.e. for mod_perl). - -=head1 METHODS - -=over 4 - -=item $c->apache_request +# 1.27 MP13 +# 1.28 MP13 +# 1.29 MP13 +# 1.2901 MP13 +# 1.30 MP13 TBR -Returns an C object. - -=item $c->original_request - -Returns the original Apache request 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; - $c->original_request->headers_out->set( - $name => $c->response->headers->header($name) ); - } - while ( my ( $name, $cookie ) = each %{ $c->response->cookies } ) { - my %cookie = ( -name => $name, -value => $cookie->{value} ); - $cookie->{-expires} = $cookie->{expires} if $cookie->{expires}; - $cookie->{-domain} = $cookie->{domain} if $cookie->{domain}; - $cookie->{-path} = $cookie->{path} if $cookie->{path}; - $cookie->{-secure} = $cookie->{secure} if $cookie->{secure}; - my $cookie = Apache::Cookie->new( $c->original_request, %cookie ); - MP2 - ? $c->apache_request->err_headers_out->add( - 'Set-Cookie' => $cookie->as_string ) - : $cookie->bake; - } - $c->original_request->status( $c->response->status ); - $c->original_request->content_type( $c->response->headers->content_type - || 'text/plain' ); - MP2 || $c->apache_request->send_http_header; - return 0; -} - -=item $c->finalize_output - -=cut +# 1.9901 MP19 +# 1.9920 MP19 +# 1.999020 MP19 RC3 +# 1.999021 MP19 RC4 -sub finalize_output { - my $c = shift; - $c->original_request->print( $c->response->{output} ); -} +# 1.999022 MP20 RC5 +# 1.999023 MP20 RC6 -=item $c->prepare_cookies - -=cut - -sub prepare_cookies { - my $c = shift; - MP2 - ? $c->req->cookies( { Apache::Cookie->fetch } ) - : $c->req->cookies( - { Apache::Cookie->new( $c->apache_request )->fetch } ); -} - -=item $c->prepare_headers - -=cut - -sub prepare_headers { - my $c = shift; - $c->req->method( $c->apache_request->method ); - $c->req->headers->header( %{ $c->apache_request->headers_in } ); -} - -=item $c->prepare_parameters - -=cut - -sub prepare_parameters { - my $c = shift; - my %args; - foreach my $key ( $c->apache_request->param ) { - my @values = $c->apache_request->param($key); - $args{$key} = @values == 1 ? $values[0] : \@values; - } - $c->req->parameters( \%args ); -} - -=item $c->prepare_path - -=cut +1; -sub prepare_path { - my $c = shift; - $c->req->path( $c->apache_request->uri ); - my $loc = $c->apache_request->location; - no warnings 'uninitialized'; - $c->req->{path} =~ s/^($loc)?\///; - my $base = URI->new; - $base->scheme( $ENV{HTTPS} ? 'https' : 'http' ); - $base->host( $c->apache_request->hostname ); - $base->port( $c->apache_request->get_server_port ); - my $path = $c->apache_request->location; - $base->path( $path =~ /\/$/ ? $path : "$path/" ); - $c->req->base( $base->as_string ); -} - -=item $c->prepare_request($r) +__END__ -=cut +=head1 NAME -sub prepare_request { - my ( $c, $r ) = @_; - $c->apache_request( Apache::Request->new($r) ); - $c->original_request($r); -} +Catalyst::Engine::Apache - Catalyst Apache Engine -=item $c->prepare_uploads +=head1 SYNOPSIS -=cut +See L. -sub prepare_uploads { - my $c = shift; - for my $upload ( $c->apache_request->upload ) { - $upload = $c->apache_request->upload($upload) if MP2; - $c->req->uploads->{ $upload->filename } = { - fh => $upload->fh, - size => $upload->size, - type => $upload->type - }; - } -} +=head1 DESCRIPTION -=back +This class will load the correct MP Engine. =head1 SEE ALSO @@ -186,6 +39,7 @@ L. =head1 AUTHOR Sebastian Riedel, C +Christian Hansen C =head1 COPYRIGHT @@ -193,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;