6415457203c092f62f36e82b334c546ddb372341
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Engine / Apache / MP13.pm
1 package Catalyst::Engine::Apache::MP13;
2
3 use strict;
4 use base 'Catalyst::Engine::Apache::Base';
5
6 use Apache            ();
7 use Apache::Constants ();
8 use Apache::Request   ();
9
10 Apache::Constants->import(':common');
11
12 =head1 NAME
13
14 Catalyst::Engine::Apache::MP13 - Catalyst Apache MP13 Engine
15
16 =head1 SYNOPSIS
17
18 See L<Catalyst>.
19
20 =head1 DESCRIPTION
21
22 This is the Catalyst engine specialized for Apache mod_perl version 1.3x.
23
24 =head1 OVERLOADED METHODS
25
26 This class overloads some methods from C<Catalyst::Engine::Apache::Base>.
27
28 =over 4
29
30 =item $c->finalize_headers
31
32 =cut
33
34 sub finalize_headers {
35     my $c = shift;
36
37     for my $name ( $c->response->headers->header_field_names ) {
38         next if $name =~ /Content-Type/i;
39         my @values = $c->response->header($name);
40         $c->apache->headers_out->add( $name => $_ ) for @values;
41     }
42
43     if ( $c->response->header('Set-Cookie') && $c->response->status >= 300 ) {
44         my @values = $c->response->header('Set-Cookie');
45         $c->apache->err_headers_out->add( 'Set-Cookie' => $_ ) for @values;
46     }
47
48     $c->apache->status( $c->response->status );
49     $c->apache->content_type( $c->response->header('Content-Type') );
50
51     $c->apache->send_http_header;
52
53     return 0;
54 }
55
56 =item $c->handler
57
58 =cut
59
60 sub handler ($$) {
61     shift->SUPER::handler(@_);
62 }
63
64 =item $c->prepare_request($r)
65
66 =cut
67
68 sub prepare_request {
69     my ( $c, $r ) = @_;
70     $c->apache( Apache::Request->new($r) );
71 }
72
73 =item $c->prepare_uploads
74
75 =cut
76
77 sub prepare_uploads {
78     my $c = shift;
79
80     my @uploads;
81
82     for my $upload ( $c->apache->upload ) {
83
84         my $object = Catalyst::Request::Upload->new(
85             filename => $upload->filename,
86             size     => $upload->size,
87             tempname => $upload->tempname,
88             type     => $upload->type
89         );
90
91         push( @uploads, $upload->name, $object );
92     }
93
94     $c->request->upload(@uploads);
95 }
96
97 =back
98
99 =head1 SEE ALSO
100
101 L<Catalyst>, L<Catalyst::Engine>, L<Catalyst::Engine::Apache::Base>.
102
103 =head1 AUTHOR
104
105 Sebastian Riedel, C<sri@cpan.org>
106 Christian Hansen C<ch@ngmedia.com>
107
108 =head1 COPYRIGHT
109
110 This program is free software, you can redistribute it and/or modify it under
111 the same terms as Perl itself.
112
113 =cut
114
115 1;