1 package Catalyst::Engine::Apache;
4 use base 'Catalyst::Engine';
9 __PACKAGE__->mk_accessors(qw/apache/);
13 Catalyst::Engine::Apache - Catalyst Apache Engine
21 This is a base class engine specialized for Apache (i.e. for mod_perl).
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->hostname( $c->apache->connection->remote_host );
76 $c->request->address( $c->apache->connection->remote_ip );
79 =item $c->prepare_headers
85 $c->request->method( $c->apache->method );
86 $c->request->header( %{ $c->apache->headers_in } );
89 =item $c->prepare_parameters
93 sub prepare_parameters {
98 $c->apache->param->do( sub {
99 my ( $field, $value ) = @_;
100 push( @params, $field, $value );
104 $c->req->_assign_values( $c->req->parameters, \@params );
107 =item $c->prepare_path
111 # XXX needs fixing, only work with <Location> directive,
112 # not <Directory> directive
115 $c->request->path( $c->apache->uri );
116 my $loc = $c->apache->location;
117 no warnings 'uninitialized';
118 $c->req->{path} =~ s/^($loc)?\///;
120 $base->scheme( $ENV{HTTPS} ? 'https' : 'http' );
121 $base->host( $c->apache->hostname );
122 $base->port( $c->apache->get_server_port );
123 my $path = $c->apache->location;
124 $base->path( $path =~ /\/$/ ? $path : "$path/" );
125 $c->request->base( $base->as_string );
142 Sebastian Riedel, C<sri@cpan.org>
143 Christian Hansen C<ch@ngmedia.com>
147 This program is free software, you can redistribute it and/or modify it under
148 the same terms as Perl itself.