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 the Catalyst 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_output
45 $c->apache->print( $c->response->output );
48 =item $c->prepare_connection
52 sub prepare_connection {
54 $c->request->hostname( $c->apache->connection->remote_host );
55 $c->request->address( $c->apache->connection->remote_ip );
58 =item $c->prepare_headers
64 $c->request->method( $c->apache->method );
65 $c->request->header( %{ $c->apache->headers_in } );
68 =item $c->prepare_parameters
72 sub prepare_parameters {
75 foreach my $key ( $c->apache->param ) {
76 my @values = $c->apache->param($key);
77 $c->req->parameters->{$key} = ( @values == 1 ) ? $values[0] : \@values;
81 =item $c->prepare_path
85 # XXX needs fixing, only work with <Location> directive,
86 # not <Directory> directive
89 $c->request->path( $c->apache->uri );
90 my $loc = $c->apache->location;
91 no warnings 'uninitialized';
92 $c->req->{path} =~ s/^($loc)?\///;
94 $base->scheme( $ENV{HTTPS} ? 'https' : 'http' );
95 $base->host( $c->apache->hostname );
96 $base->port( $c->apache->get_server_port );
97 my $path = $c->apache->location;
98 $base->path( $path =~ /\/$/ ? $path : "$path/" );
99 $c->request->base( $base->as_string );
102 =item $c->prepare_request($r)
106 sub prepare_request {
108 $c->apache( $ENV{MOD_PERL_API_VERSION} == 2
109 ? Apache2::Request->new($r)
110 : Apache::Request->new($r) );
127 Sebastian Riedel, C<sri@cpan.org>
131 This program is free software, you can redistribute it and/or modify it under
132 the same terms as Perl itself.