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