X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine%2FApache.pm;h=a9bd2c8e60f04ff01f14153eec58c8ac7d251567;hb=c24122df7669010c2e7209ce40eced3b4cd04183;hp=e3c523043b63ebe0418e35e551efbf4eb5dc527a;hpb=bfde09a29c9b25cca920350488ddda743a606031;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine/Apache.pm b/lib/Catalyst/Engine/Apache.pm index e3c5230..a9bd2c8 100644 --- a/lib/Catalyst/Engine/Apache.pm +++ b/lib/Catalyst/Engine/Apache.pm @@ -1,12 +1,7 @@ package Catalyst::Engine::Apache; use strict; -use base 'Catalyst::Engine'; - -use URI; -use URI::http; - -__PACKAGE__->mk_accessors(qw/apache/); +use UNIVERSAL::require; =head1 NAME @@ -18,125 +13,7 @@ See L. =head1 DESCRIPTION -This is a base class 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_body - -=cut - -sub finalize_body { - my $c = shift; - $c->apache->print( $c->response->body ); -} - -=item $c->prepare_body - -=cut - -sub prepare_body { - my $c = shift; - - my $length = $c->request->content_length; - my ( $buffer, $content ); - - while ($length) { - - $c->apache->read( $buffer, ( $length < 8192 ) ? $length : 8192 ); - - $length -= length($buffer); - $content .= $buffer; - } - - $c->request->body($content); -} - -=item $c->prepare_connection - -=cut - -sub prepare_connection { - my $c = shift; - $c->request->address( $c->apache->connection->remote_ip ); - $c->request->hostname( $c->apache->connection->remote_host ); - $c->request->protocol( $c->apache->protocol ); - - if ( $ENV{HTTPS} ) { - $c->request->secure(1); - } -} - -=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 @params; - - $c->apache->param->do( sub { - my ( $field, $value ) = @_; - push( @params, $field, $value ); - return 1; - }); - - $c->request->param(@params); -} - -=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->run - -=cut - -sub run { } - -=back +This class will load the correct MP Engine. =head1 SEE ALSO