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