fcgi engine
Sebastian Riedel [Tue, 22 Mar 2005 23:44:31 +0000 (23:44 +0000)]
Changes
lib/Catalyst/Engine/FCGI.pm [new file with mode: 0644]
lib/Catalyst/Helper.pm

diff --git a/Changes b/Changes
index 3452c54..37100ac 100644 (file)
--- a/Changes
+++ b/Changes
@@ -4,7 +4,7 @@ This file documents the revision history for Perl extension Catalyst.
         - documented the log() accessor method in Catalyst (Andrew Ford)
         - added optional arguments to Catalyst::Log methods (Andrew Ford)
         - removed cgi-server.pl
-        - added fcgi.pl
+        - added fcgi.pl and Catalyst::Engine::FCGI
         - fixed an undef durng make test (Dan Sully)
 
 4.32  Tue Mar 22 02:10:00 2005
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;
index b9b2f5d..8f16fb8 100644 (file)
@@ -325,10 +325,7 @@ sub _mk_cgi {
     $self->mk_file( "$script\/nph-cgi.pl", <<"EOF");
 $Config{startperl} -w
 
-BEGIN {
-    \$ENV{CATALYST_ENGINE} = 'CGI';
-    \$ENV{CATALYST_TEST}   = 1;
-}
+BEGIN { \$ENV{CATALYST_ENGINE} = 'CGI' }
 
 use strict;
 use FindBin;
@@ -375,28 +372,14 @@ sub _mk_fcgi {
     $self->mk_file( "$script\/fcgi.pl", <<"EOF");
 $Config{startperl} -w
 
-BEGIN {
-    \$ENV{CATALYST_ENGINE} = 'CGI';
-    \$ENV{CATALYST_TEST}   = 1;
-}
+BEGIN { \$ENV{CATALYST_ENGINE} = 'FCGI' }
 
 use strict;
 use FindBin;
 use lib "\$FindBin::Bin/../lib";
-use FCGI;
 use $name;
 
-my \$request = FCGI::Request();
-while ( \$request->Accept() >= 0 ) {
-    my \$output;
-    {
-        local(*STDOUT);
-        open( STDOUT, '>', \\\$output );
-        $name->run;
-    }
-    \$output =~ s!^HTTP/\\d+.\\d+ \\d\\d\\d.*?\\n!!s;
-    print \$output;
-}
+$name->run;
 
 1;
 __END__
@@ -436,10 +419,7 @@ sub _mk_server {
     $self->mk_file( "$script\/server.pl", <<"EOF");
 $Config{startperl} -w
 
-BEGIN { 
-    \$ENV{CATALYST_ENGINE} = 'Server';
-    \$ENV{CATALYST_TEST}   = 1;
-}
+BEGIN { \$ENV{CATALYST_ENGINE} = 'Server' }
 
 use strict;
 use Getopt::Long;