added C::E::CGI::NPH
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Engine / CGI / NPH.pm
1 package Catalyst::Engine::CGI::NPH;
2
3 use strict;
4 use base 'Catalyst::Engine::CGI';
5
6 =head1 NAME
7
8 Catalyst::Engine::CGI::NPH - Catalyst CGI Engine
9
10 =head1 SYNOPSIS
11
12 See L<Catalyst>.
13
14 =head1 DESCRIPTION
15
16 This Catalyst engine returns a complete HTTP response message.
17
18 =head1 OVERLOADED METHODS
19
20 This class overloads some methods from C<Catalyst::Engine::CGI>.
21
22 =over 4
23
24 =item $c->finalize_headers
25
26 =cut
27
28 sub finalize_headers {
29     my $c = shift;
30     my %headers = ( -nph => 1 );
31     $headers{-status} = $c->response->status if $c->response->status;
32     for my $name ( $c->response->headers->header_field_names ) {
33         $headers{"-$name"} = $c->response->headers->header($name);
34     }
35     my @cookies;
36     while ( my ( $name, $cookie ) = each %{ $c->response->cookies } ) {
37         push @cookies, $c->cgi->cookie(
38             -name    => $name,
39             -value   => $cookie->{value},
40             -expires => $cookie->{expires},
41             -domain  => $cookie->{domain},
42             -path    => $cookie->{path},
43             -secure  => $cookie->{secure} || 0
44         );
45     }
46     $headers{-cookie} = \@cookies if @cookies;
47     print $c->cgi->header(%headers);
48 }
49
50 =back
51
52 =head1 SEE ALSO
53
54 L<Catalyst>, L<Catalyst::Engine::CGI>.
55
56 =head1 AUTHOR
57
58 Sebastian Riedel, C<sri@cpan.org>
59 Christian Hansen, C<ch@ngmedia.com>
60
61 =head1 COPYRIGHT
62
63 This program is free software, you can redistribute it and/or modify it under
64 the same terms as Perl itself.
65
66 =cut
67
68 1;