Reworked Engine namespaces
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Engine / HTTP.pm
index 598670d..4ec9fb3 100644 (file)
@@ -1,9 +1,7 @@
 package Catalyst::Engine::HTTP;
 
 use strict;
-use base 'Catalyst::Engine::Test';
-
-use IO::Socket qw(AF_INET INADDR_ANY SOCK_STREAM SOMAXCONN);
+use base 'Catalyst::Engine::HTTP::Daemon';
 
 =head1 NAME
 
@@ -27,71 +25,9 @@ A script using the Catalyst::Engine::HTTP module might look like:
 
 This is the Catalyst engine specialized for development and testing.
 
-=head1 OVERLOADED METHODS
-
-This class overloads some methods from C<Catalyst::Engine::Test>.
-
-=over 4
-
-=item $c->run
-
-=cut
-
-$SIG{'PIPE'} = 'IGNORE';
-
-sub run {
-    my $class = shift;
-    my $port  = shift || 3000;
-
-    my $daemon = Catalyst::Engine::HTTP::Catalyst->new(
-        Listen    => SOMAXCONN,
-        LocalPort => $port,
-        ReuseAddr => 1,
-        Type      => SOCK_STREAM,
-    );
-
-    unless ($daemon) {
-        die("Failed to create daemon: $!\n");
-    }
-
-    my $base = URI->new( $daemon->url )->canonical;
-
-    printf( "You can connect to your server at %s\n", $base );
-
-    while ( my $connection = $daemon->accept ) {
-
-        $connection->timeout(5);
-
-        while ( my $request = $connection->get_request ) {
-
-            $request->uri->scheme('http');    # Force URI::http
-            $request->uri->host( $request->header('Host') || $base->host );
-            $request->uri->port( $base->port );
-            
-            my $hostname = gethostbyaddr( $connection->peeraddr, AF_INET );
-
-            my $http = Catalyst::Engine::Test::HTTP->new(
-                address  => $connection->peerhost,
-                hostname => $hostname || $connection->peerhost,
-                request  => $request,
-                response => HTTP::Response->new
-            );
-
-            $class->handler($http);
-            $connection->send_response( $http->response );
-
-        }
-
-        $connection->close;
-        undef($connection);
-    }
-}
-
-=back
-
 =head1 SEE ALSO
 
-L<Catalyst>, L<HTTP::Daemon>.
+L<Catalyst>, L<Catalyst::Engine>, L<Catalyst::Engine::HTTP::Daemon>.
 
 =head1 AUTHOR
 
@@ -105,13 +41,4 @@ the same terms as Perl itself.
 
 =cut
 
-package Catalyst::Engine::HTTP::Catalyst;
-
-use strict;
-use base 'HTTP::Daemon';
-
-sub product_tokens {
-    "Catalyst/$Catalyst::VERSION";
-}
-
 1;