Merged 5.49_01 (r1339) from refactored branch to trunk
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Engine / FastCGI.pm
1 package Catalyst::Engine::FastCGI;
2
3 use strict;
4 use base 'Catalyst::Engine::CGI';
5 use FCGI;
6
7 =head1 NAME
8
9 Catalyst::Engine::FastCGI - FastCGI Engine
10
11 =head1 DESCRIPTION
12
13 This is the FastCGI engine.
14
15 =head1 OVERLOADED METHODS
16
17 This class overloads some methods from C<Catalyst::Engine::CGI>.
18
19 =over 4
20
21 =item $self->run($c)
22
23 =cut
24
25 sub run {
26     my ( $self, $class ) = @_;
27
28     my $request = FCGI::Request();
29
30     while ( $request->Accept >= 0 ) {
31         $class->handle_request;
32     }
33 }
34
35 =item $self->write($c, $buffer)
36
37 =cut
38
39 sub write {
40     my ( $self, $c, $buffer ) = @_;
41     
42     unless ( $self->{_prepared_write} ) {
43         $self->prepare_write( $c );
44         $self->{_prepared_write} = 1;
45     }
46     
47     # FastCGI does not stream data properly if using 'print $handle',
48     # but a syswrite appears to work properly.
49     $c->response->handle->syswrite( $buffer );
50 }
51
52 =back
53
54 =head1 SEE ALSO
55
56 L<Catalyst>, L<FCGI>.
57
58 =head1 AUTHORS
59
60 Sebastian Riedel, <sri@cpan.org>
61
62 Christian Hansen, <ch@ngmedia.com>
63
64 Andy Grundman, <andy@hybridized.org>
65
66 =head1 COPYRIGHT
67
68 This program is free software, you can redistribute it and/or modify it under
69 the same terms as Perl itself.
70
71 =cut
72
73 1;