Commit | Line | Data |
111728e3 |
1 | package Catalyst::Engine::Apache::MP19; |
479d2af4 |
2 | |
3 | use strict; |
c2e8e6fa |
4 | use base 'Catalyst::Engine::Apache::Base'; |
479d2af4 |
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 (); |
e7c0c583 |
13 | use Apache::Upload (); |
479d2af4 |
14 | |
e7c0c583 |
15 | Apache::Const->import( -compile => ':common' ); |
479d2af4 |
16 | |
17 | =head1 NAME |
18 | |
22a23d06 |
19 | Catalyst::Engine::Apache::MP19 - Catalyst Apache MP19 Engine |
479d2af4 |
20 | |
21 | =head1 SYNOPSIS |
22 | |
23 | See L<Catalyst>. |
24 | |
25 | =head1 DESCRIPTION |
26 | |
06e1b616 |
27 | This is the Catalyst engine specialized for Apache mod_perl version 1.9x. |
479d2af4 |
28 | |
29 | =head1 OVERLOADED METHODS |
30 | |
c2e8e6fa |
31 | This class overloads some methods from C<Catalyst::Engine::Apache::Base>. |
479d2af4 |
32 | |
33 | =over 4 |
34 | |
e7c0c583 |
35 | =item $c->finalize_headers |
36 | |
37 | =cut |
38 | |
39 | sub finalize_headers { |
40 | my $c = shift; |
41 | |
42 | for my $name ( $c->response->headers->header_field_names ) { |
43 | next if $name =~ /Content-Type/i; |
44 | my @values = $c->response->header($name); |
45 | $c->apache->headers_out->add( $name => $_ ) for @values; |
46 | } |
47 | |
48 | if ( $c->response->header('Set-Cookie') && $c->response->status >= 300 ) { |
49 | my @values = $c->response->header('Set-Cookie'); |
50 | $c->apache->err_headers_out->add( 'Set-Cookie' => $_ ) for @values; |
51 | } |
52 | |
53 | $c->apache->status( $c->response->status ); |
54 | $c->apache->content_type( $c->response->header('Content-Type') ); |
55 | |
56 | return 0; |
57 | } |
58 | |
479d2af4 |
59 | =item $c->handler |
60 | |
e7c0c583 |
61 | =cut |
62 | |
63 | sub handler : method { |
64 | shift->SUPER::handler(@_); |
65 | } |
66 | |
329a7e51 |
67 | =item $c->prepare_request($r) |
68 | |
69 | =cut |
70 | |
71 | sub prepare_request { |
72 | my ( $c, $r ) = @_; |
73 | $c->apache( Apache::Request->new($r) ); |
74 | } |
75 | |
e7c0c583 |
76 | =item $c->prepare_uploads |
77 | |
78 | =cut |
79 | |
80 | sub prepare_uploads { |
81 | my $c = shift; |
82 | |
bfde09a2 |
83 | # This is a workaround for a know bug with libapreq <= 2.0.4 |
b9e9fff6 |
84 | # http://svn.apache.org/viewcvs.cgi?rev=122925&view=rev |
06e1b616 |
85 | |
b9e9fff6 |
86 | my @uploads; |
87 | |
06e1b616 |
88 | for my $field ( $c->request->param ) { |
e7c0c583 |
89 | |
90 | for my $upload ( $c->apache->upload($field) ) { |
91 | |
146554c5 |
92 | my $object = Catalyst::Request::Upload->new( |
e7c0c583 |
93 | filename => $upload->filename, |
94 | size => $upload->size, |
95 | tempname => $upload->tempname, |
96 | type => $upload->type |
146554c5 |
97 | ); |
e7c0c583 |
98 | |
146554c5 |
99 | push( @uploads, $field, $object ); |
e7c0c583 |
100 | } |
101 | } |
102 | |
bfde09a2 |
103 | $c->request->upload(@uploads); |
06e1b616 |
104 | } |
105 | |
479d2af4 |
106 | =back |
107 | |
108 | =head1 SEE ALSO |
109 | |
c2e8e6fa |
110 | L<Catalyst>, L<Catalyst::Engine>, L<Catalyst::Engine::Apache::Base>. |
479d2af4 |
111 | |
112 | =head1 AUTHOR |
113 | |
114 | Sebastian Riedel, C<sri@cpan.org> |
329a7e51 |
115 | Christian Hansen C<ch@ngmedia.com> |
479d2af4 |
116 | |
117 | =head1 COPYRIGHT |
118 | |
119 | This program is free software, you can redistribute it and/or modify it under |
120 | the same terms as Perl itself. |
121 | |
122 | =cut |
123 | |
124 | 1; |