- removed C::E::Server
Christian Hansen [Fri, 25 Mar 2005 19:13:03 +0000 (19:13 +0000)]
- Detect C::E::Server in Catalyst.pm, use C::E::H::Daemon instead
- moved back C:E:LWP::Daemon to C::E::HTTP:Daemon
- rename $ENV{CATALYST_REMOTE} with $ENV{CATALYST_SERVER}
- updated helper script server.pl
- prevent Catalyst->import from being called twice
- added $class->import in C::Test

lib/Catalyst.pm
lib/Catalyst/Engine/HTTP/Daemon.pm [moved from lib/Catalyst/Engine/LWP/Daemon.pm with 83% similarity]
lib/Catalyst/Engine/LWP.pm
lib/Catalyst/Engine/Server.pm [deleted file]
lib/Catalyst/Helper.pm
lib/Catalyst/Test.pm

index 26047c3..328a358 100644 (file)
@@ -146,6 +146,10 @@ sub import {
         push @{"$caller\::ISA"}, $self;
     }
 
+    if ( $caller->engine ) {
+        return; # Catalyst is allready initialized
+    }
+
     unless ( $caller->log ) {
         $caller->log( Catalyst::Log->new );
     }
@@ -190,6 +194,13 @@ sub import {
     # Engine
     $engine = "Catalyst::Engine::$ENV{CATALYST_ENGINE}"
       if $ENV{CATALYST_ENGINE};
+
+    if ( $engine eq 'Catalyst::Engine::Server' ) {
+        $engine = 'Catalyst::Engine::HTTP::Daemon';
+        $caller->log->warn(  "Catalyst::Engine::Server is deprecated, "
+                           . "using Catalyst::Engine::HTTP::Daemon." );
+    }
+
     $engine->require;
     die qq/Couldn't load engine "$engine", "$@"/ if $@;
     {
similarity index 83%
rename from lib/Catalyst/Engine/LWP/Daemon.pm
rename to lib/Catalyst/Engine/HTTP/Daemon.pm
index 84b9c27..65129ee 100644 (file)
@@ -1,4 +1,4 @@
-package Catalyst::Engine::LWP::Daemon;
+package Catalyst::Engine::HTTP::Daemon;
 
 use strict;
 use base 'Catalyst::Engine::LWP';
@@ -7,16 +7,16 @@ use IO::Socket qw(AF_INET);
 
 =head1 NAME
 
-Catalyst::Engine::LWP::Daemon - Catalyst LWP Daemon Engine
+Catalyst::Engine::HTTP::Daemon - Catalyst HTTP Daemon Engine
 
 =head1 SYNOPSIS
 
-A script using the Catalyst::Engine::LWP::Daemon module might look like:
+A script using the Catalyst::Engine::HTTP::Daemon module might look like:
 
     #!/usr/bin/perl -w
 
     BEGIN { 
-       $ENV{CATALYST_ENGINE} = 'LWP::Daemon';
+       $ENV{CATALYST_ENGINE} = 'HTTP::Daemon';
     }
 
     use strict;
@@ -45,7 +45,7 @@ sub run {
     my $class = shift;
     my $port  = shift || 3000;
 
-    my $daemon = Catalyst::Engine::LWP::Daemon::Catalyst->new(
+    my $daemon = Catalyst::Engine::HTTP::Daemon::Catalyst->new(
         LocalPort => $port,
         ReuseAddr => 1
     );
@@ -95,7 +95,7 @@ the same terms as Perl itself.
 
 =cut
 
-package Catalyst::Engine::LWP::Daemon::Catalyst;
+package Catalyst::Engine::HTTP::Daemon::Catalyst;
 
 use strict;
 use base 'HTTP::Daemon';
index 01580a0..ae24063 100644 (file)
@@ -91,7 +91,7 @@ sub prepare_connection {
 sub prepare_cookies {
     my $c = shift;
 
-    if ( my $header = $c->lwp->request->header('Cookie') ) {
+    if ( my $header = $c->request->headers->header('Cookie') ) {
         $c->req->cookies( { CGI::Simple::Cookie->parse($header) } );
     }
 }
diff --git a/lib/Catalyst/Engine/Server.pm b/lib/Catalyst/Engine/Server.pm
deleted file mode 100644 (file)
index 8db6d33..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-package Catalyst::Engine::Server;
-
-use strict;
-use base 'Catalyst::Engine::LWP::Daemon';
-
-=head1 NAME
-
-Catalyst::Engine::Server - Catalyst Server Engine
-
-=head1 SYNOPSIS
-
-A script using the Catalyst::Engine::Server module might look like:
-
-    #!/usr/bin/perl -w
-
-    BEGIN { 
-       $ENV{CATALYST_ENGINE} = 'Server';
-    }
-
-    use strict;
-    use lib '/path/to/MyApp/lib';
-    use MyApp;
-
-    MyApp->run;
-
-=head1 DESCRIPTION
-
-This is the Catalyst engine specialized for development and testing.
-
-=head1 SEE ALSO
-
-L<Catalyst>, L<Catalyst::Engine::LWP::Daemon>.
-
-=head1 AUTHOR
-
-Sebastian Riedel, C<sri@cpan.org>
-Christian Hansen, C<ch@ngmedia.com>
-
-=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 8c392cb..71efd7d 100644 (file)
@@ -476,7 +476,7 @@ sub _mk_server {
     $self->mk_file( "$script\/server.pl", <<"EOF");
 $Config{startperl} -w
 
-BEGIN { \$ENV{CATALYST_ENGINE} = 'Server' }
+BEGIN { \$ENV{CATALYST_ENGINE} = 'HTTP::Daemon' }
 
 use strict;
 use Getopt::Long;
index 3de24ad..4ca73ee 100644 (file)
@@ -20,7 +20,7 @@ Catalyst::Test - Test Catalyst applications
     get('index.html');
 
     # Run tests against a remote server
-    CATALYST_REMOTE='http://localhost:3000/' prove -l lib/ t/
+    CATALYST_SERVER='http://localhost:3000/' prove -l lib/ t/
 
     # Tests with inline apps need to use Catalyst::Engine::Test
     package TestApp;
@@ -67,17 +67,20 @@ sub import {
 
     my ( $get, $request );
 
-    if ( $ENV{CATALYST_REMOTE} ) {
+    if ( $ENV{CATALYST_SERVER} ) {
         $request = sub { remote_request(@_) };
         $get     = sub { remote_request(@_)->content };
     }
 
     else {
         $class->require;
+
         unless ( $INC{'Test/Builder.pm'} ) {
             die qq/Couldn't load "$class", "$@"/ if $@;
         }
 
+        $class->import;
+
         $request = sub { $class->run(@_) };
         $get     = sub { $class->run(@_)->content };
     }
@@ -93,7 +96,7 @@ sub remote_request {
 
     require LWP::UserAgent;
 
-    my $remote = URI->new( $ENV{CATALYST_REMOTE} );
+    my $remote = URI->new( $ENV{CATALYST_SERVER} );
 
     unless ( ref $request ) {