1 package Catalyst::Engine::Apache::Base;
4 use base qw[Catalyst::Engine Catalyst::Engine::Apache];
9 __PACKAGE__->mk_accessors(qw/apache/);
13 Catalyst::Engine::Apache::Base - Base class for Apache Engines
21 This is a base class for Apache Engines.
29 Returns an C<Apache::Request> object.
33 =head1 OVERLOADED METHODS
35 This class overloads some methods from C<Catalyst::Engine>.
39 =item $c->finalize_body
45 $c->apache->print( $c->response->body );
48 =item $c->prepare_body
55 my $length = $c->request->content_length;
56 my ( $buffer, $content );
60 $c->apache->read( $buffer, ( $length < 8192 ) ? $length : 8192 );
62 $length -= length($buffer);
66 $c->request->body($content);
69 =item $c->prepare_connection
73 sub prepare_connection {
75 $c->request->address( $c->apache->connection->remote_ip );
76 $c->request->hostname( $c->apache->connection->remote_host );
77 $c->request->protocol( $c->apache->protocol );
78 $c->request->user( $c->apache->user );
80 if ( $ENV{HTTPS} || $c->apache->get_server_port == 443 ) {
81 $c->request->secure(1);
85 =item $c->prepare_headers
91 $c->request->method( $c->apache->method );
92 $c->request->header( %{ $c->apache->headers_in } );
95 =item $c->prepare_path
99 # XXX needs fixing, only work with <Location> directive,
100 # not <Directory> directive
106 my $scheme = $c->request->secure ? 'https' : 'http';
107 my $host = $c->apache->hostname;
108 my $port = $c->apache->get_server_port;
109 my $path = $c->apache->location || '/';
111 unless ( $path =~ /\/$/ ) {
116 $base->scheme($scheme);
121 $base = $base->canonical->as_string;
124 my $location = $c->apache->location || '/';
125 my $path = $c->apache->uri || '/';
126 $path =~ s/^($location)?\///;
129 $c->req->base($base);
130 $c->req->path($path);
133 =item $c->prepare_request($r)
137 sub prepare_request {
152 L<Catalyst> L<Catalyst::Engine>.
156 Sebastian Riedel, C<sri@cpan.org>
157 Christian Hansen C<ch@ngmedia.com>
161 This program is free software, you can redistribute it and/or modify it under
162 the same terms as Perl itself.