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