fcgi engine
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Engine / FCGI.pm
diff --git a/lib/Catalyst/Engine/FCGI.pm b/lib/Catalyst/Engine/FCGI.pm
new file mode 100644 (file)
index 0000000..0ee022b
--- /dev/null
@@ -0,0 +1,62 @@
+package Catalyst::Engine::FCGI;
+
+use strict;
+use base 'Catalyst::Engine::CGI';
+use FCGI;
+use NEXT;
+
+=head1 NAME
+
+Catalyst::Engine::FCGI - Catalyst FCGI Engine
+
+=head1 SYNOPSIS
+
+See L<Catalyst>.
+
+=head1 DESCRIPTION
+
+This is the Catalyst engine for FastCGI.
+
+=head1 OVERLOADED METHODS
+
+This class overloads some methods from C<Catalyst::Engine::CGI>.
+
+=over 4
+
+=item $c->run
+
+=cut
+
+sub run {
+    my $class   = shift;
+    my $request = FCGI::Request();
+    while ( $request->Accept() >= 0 ) {
+        my $output;
+        {
+            local (*STDOUT);
+            open( STDOUT, '>', \$output );
+            $class->NEXT::run;
+        }
+        $output =~ s!^HTTP/\d+.\d+ \d\d\d.*?\n!!s;
+        print $output;
+    }
+}
+
+=back
+
+=head1 SEE ALSO
+
+L<Catalyst>.
+
+=head1 AUTHOR
+
+Sebastian Riedel, C<sri@cpan.org>
+
+=head1 COPYRIGHT
+
+This program is free software, you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
+=cut
+
+1;