Updated changes file
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Engine / Apache / MP19.pm
CommitLineData
111728e3 1package Catalyst::Engine::Apache::MP19;
479d2af4 2
3use strict;
c2e8e6fa 4use base 'Catalyst::Engine::Apache::Base';
479d2af4 5
e7c0c583 6use Apache2 ();
7use Apache::Connection ();
8use Apache::Const ();
9use Apache::RequestIO ();
10use Apache::RequestRec ();
479d2af4 11use Apache::RequestUtil ();
e7c0c583 12use Apache::Request ();
e7c0c583 13use Apache::Upload ();
479d2af4 14
e7c0c583 15Apache::Const->import( -compile => ':common' );
479d2af4 16
17=head1 NAME
18
22a23d06 19Catalyst::Engine::Apache::MP19 - Catalyst Apache MP19 Engine
479d2af4 20
21=head1 SYNOPSIS
22
23See L<Catalyst>.
24
25=head1 DESCRIPTION
26
06e1b616 27This is the Catalyst engine specialized for Apache mod_perl version 1.9x.
479d2af4 28
29=head1 OVERLOADED METHODS
30
c2e8e6fa 31This 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
39sub 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
63sub handler : method {
64 shift->SUPER::handler(@_);
65}
66
329a7e51 67=item $c->prepare_request($r)
68
69=cut
70
71sub 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
80sub 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 110L<Catalyst>, L<Catalyst::Engine>, L<Catalyst::Engine::Apache::Base>.
479d2af4 111
112=head1 AUTHOR
113
114Sebastian Riedel, C<sri@cpan.org>
329a7e51 115Christian Hansen C<ch@ngmedia.com>
479d2af4 116
117=head1 COPYRIGHT
118
119This program is free software, you can redistribute it and/or modify it under
120the same terms as Perl itself.
121
122=cut
123
1241;