Added recursive -r flag to prove example
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Engine / Apache / MP19 / Base.pm
1 package Catalyst::Engine::Apache::MP19::Base;
2
3 use strict;
4 use base 'Catalyst::Engine::Apache::Base';
5
6 use Apache2             ();
7 use Apache::Connection  ();
8 use Apache::Const       ();
9 use Apache::RequestIO   ();
10 use Apache::RequestRec  ();
11 use Apache::RequestUtil ();
12 use Apache::Response    ();
13
14 Apache::Const->import( -compile => ':common' );
15
16 =head1 NAME
17
18 Catalyst::Engine::Apache::MP19::Base - Base class for MP 1.9 Engines
19
20 =head1 SYNOPSIS
21
22 See L<Catalyst>.
23
24 =head1 DESCRIPTION
25
26 This is a base class for MP 1.99 Engines.
27
28 =head1 OVERLOADED METHODS
29
30 This class overloads some methods from C<Catalyst::Engine::Apache::Base>.
31
32 =over 4
33
34 =item $c->finalize_headers
35
36 =cut
37
38 sub finalize_headers {
39     my $c = shift;
40
41     for my $name ( $c->response->headers->header_field_names ) {
42         next if $name =~ /^Content-(Length|Type)$/i;
43         my @values = $c->response->header($name);
44         $c->apache->headers_out->add( $name => $_ ) for @values;
45     }
46
47     if ( $c->response->header('Set-Cookie') && $c->response->status >= 300 ) {
48         my @values = $c->response->header('Set-Cookie');
49         $c->apache->err_headers_out->add( 'Set-Cookie' => $_ ) for @values;
50     }
51
52     $c->apache->status( $c->response->status );
53
54     if ( my $type = $c->response->header('Content-Type') ) {
55         $c->apache->content_type($type);
56     }
57
58     if ( my $length = $c->response->content_length ) {
59         $c->apache->set_content_length($length);
60     }
61
62     return 0;
63 }
64
65 =item $c->handler
66
67 =cut
68
69 sub handler : method {
70     shift->SUPER::handler(@_);
71 }
72
73 =back
74
75 =head1 SEE ALSO
76
77 L<Catalyst>, L<Catalyst::Engine>, L<Catalyst::Engine::Apache::Base>.
78
79 =head1 AUTHOR
80
81 Sebastian Riedel, C<sri@cpan.org>
82 Christian Hansen C<ch@ngmedia.com>
83
84 =head1 COPYRIGHT
85
86 This program is free software, you can redistribute it and/or modify it under
87 the same terms as Perl itself.
88
89 =cut
90
91 1;