Commit | Line | Data |
300aea89 |
1 | package Catalyst::Engine::Apache::MP20; |
2 | |
3 | use strict; |
c2e8e6fa |
4 | use base 'Catalyst::Engine::Apache::Base'; |
300aea89 |
5 | |
300aea89 |
6 | use Apache2::Connection (); |
7 | use Apache2::Const (); |
8 | use Apache2::RequestIO (); |
9 | use Apache2::RequestRec (); |
10 | use Apache2::RequestUtil (); |
15b7268e |
11 | use Apache2::Request (); |
15b7268e |
12 | use Apache2::Upload (); |
300aea89 |
13 | |
14 | Apache2::Const->import( -compile => ':common' ); |
15 | |
16 | =head1 NAME |
17 | |
18 | Catalyst::Engine::Apache::MP20 - Catalyst Apache MP20 Engine |
19 | |
20 | =head1 SYNOPSIS |
21 | |
22 | See L<Catalyst>. |
23 | |
24 | =head1 DESCRIPTION |
25 | |
329a7e51 |
26 | This is the Catalyst engine specialized for Apache mod_perl version 2.0. |
300aea89 |
27 | |
28 | =head1 OVERLOADED METHODS |
29 | |
c2e8e6fa |
30 | This class overloads some methods from C<Catalyst::Engine::Apache::Base>. |
300aea89 |
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-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 | $c->apache->content_type( $c->response->header('Content-Type') ); |
54 | |
55 | return 0; |
56 | } |
57 | |
58 | =item $c->handler |
59 | |
60 | =cut |
61 | |
62 | sub handler : method { |
63 | shift->SUPER::handler(@_); |
64 | } |
65 | |
329a7e51 |
66 | =item $c->prepare_request($r) |
67 | |
68 | =cut |
69 | |
70 | sub prepare_request { |
71 | my ( $c, $r ) = @_; |
72 | $c->apache( Apache2::Request->new($r) ); |
73 | } |
74 | |
300aea89 |
75 | =item $c->prepare_uploads |
76 | |
77 | =cut |
78 | |
79 | sub prepare_uploads { |
80 | my $c = shift; |
81 | |
82 | my @uploads; |
83 | |
b9e9fff6 |
84 | $c->apache->upload->do( sub { |
85 | my ( $field, $upload ) = @_; |
300aea89 |
86 | |
b9e9fff6 |
87 | my $object = Catalyst::Request::Upload->new( |
88 | filename => $upload->filename, |
89 | size => $upload->size, |
90 | tempname => $upload->tempname, |
91 | type => $upload->type |
92 | ); |
300aea89 |
93 | |
b9e9fff6 |
94 | push( @uploads, $field, $object ); |
300aea89 |
95 | |
b9e9fff6 |
96 | return 1; |
97 | }); |
300aea89 |
98 | |
bfde09a2 |
99 | $c->request->upload(@uploads); |
300aea89 |
100 | } |
101 | |
102 | =back |
103 | |
104 | =head1 SEE ALSO |
105 | |
c2e8e6fa |
106 | L<Catalyst>, L<Catalyst::Engine>, L<Catalyst::Engine::Apache::Base>. |
300aea89 |
107 | |
108 | =head1 AUTHOR |
109 | |
110 | Sebastian Riedel, C<sri@cpan.org> |
329a7e51 |
111 | Christian Hansen C<ch@ngmedia.com> |
300aea89 |
112 | |
113 | =head1 COPYRIGHT |
114 | |
115 | This program is free software, you can redistribute it and/or modify it under |
116 | the same terms as Perl itself. |
117 | |
118 | =cut |
119 | |
120 | 1; |