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