1 package Catalyst::Engine::Apache::Base;
4 use base qw[Catalyst::Engine Catalyst::Engine::Apache];
10 __PACKAGE__->mk_accessors(qw/apache/);
14 Catalyst::Engine::Apache::Base - Base class for Apache Engines
22 This is a base class for Apache Engines.
30 Returns an C<Apache::Request> object.
34 =head1 OVERLOADED METHODS
36 This class overloads some methods from C<Catalyst::Engine>.
40 =item $c->finalize_body
46 $c->apache->print( $c->response->body );
49 =item $c->prepare_body
56 my $length = $c->request->content_length;
57 my ( $buffer, $content );
61 $c->apache->read( $buffer, ( $length < 8192 ) ? $length : 8192 );
63 $length -= length($buffer);
67 $c->request->body($content);
70 =item $c->prepare_connection
74 sub prepare_connection {
76 $c->request->address( $c->apache->connection->remote_ip );
77 $c->request->hostname( $c->apache->connection->remote_host );
78 $c->request->protocol( $c->apache->protocol );
79 $c->request->user( $c->apache->user );
81 if ( $ENV{HTTPS} || $c->apache->get_server_port == 443 ) {
82 $c->request->secure(1);
86 =item $c->prepare_headers
92 $c->request->method( $c->apache->method );
93 $c->request->header( %{ $c->apache->headers_in } );
96 =item $c->prepare_path
100 # XXX needs fixing, only work with <Location> directive,
101 # not <Directory> directive
106 my $path = $c->apache->uri;
108 if ( my $location = $c->apache->location ) {
110 if ( index( $path, $location ) == 0 ) {
111 $path = substr( $path, length($location) );
117 if ( my $filename = $c->apache->filename ) {
119 $filename = ( File::Spec->splitpath($filename) )[2];
121 if ( index( $path, $filename ) == 0 ) {
122 $path = substr( $path, length($filename) );
128 $c->request->path($path);
132 my $scheme = $c->request->secure ? 'https' : 'http';
133 my $host = $c->apache->hostname;
134 my $port = $c->apache->get_server_port;
135 my $path = $c->apache->uri;
137 if ( length( $c->request->path ) ) {
139 $path = substr( $path, 0, length($path) - length($c->req->path) );
142 unless ( $path =~ /\/$/ ) {
147 $base->scheme($scheme);
152 $c->request->base( $base->canonical->as_string );
156 =item $c->prepare_request($r)
160 sub prepare_request {
169 sub run { shift->handler(@_) }
175 L<Catalyst> L<Catalyst::Engine>.
179 Sebastian Riedel, C<sri@cpan.org>
180 Christian Hansen C<ch@ngmedia.com>
184 This program is free software, you can redistribute it and/or modify it under
185 the same terms as Perl itself.