X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine%2FHTTP.pm;h=4ec9fb3b85dd78df723db702e330f0531dd4ebb4;hb=993862744fe3f35dc8f3afc7741e25341630e69c;hp=93327459cd9e9b6341c3c13d9abc1f1a23956fef;hpb=1a80619d839bc8dd6321648d8140a795bf85025e;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine/HTTP.pm b/lib/Catalyst/Engine/HTTP.pm index 9332745..4ec9fb3 100644 --- a/lib/Catalyst/Engine/HTTP.pm +++ b/lib/Catalyst/Engine/HTTP.pm @@ -1,9 +1,7 @@ package Catalyst::Engine::HTTP; use strict; -use base 'Catalyst::Engine::Test'; - -use IO::Socket qw(AF_INET SOCK_STREAM SOMAXCONN); +use base 'Catalyst::Engine::HTTP::Daemon'; =head1 NAME @@ -27,73 +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. - -=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( $base->host ); - $request->uri->port( $base->port ); - - my $lwp = Catalyst::Engine::Test::LWP->new( - address => $connection->peerhost, - hostname => gethostbyaddr( $connection->peeraddr, AF_INET ), - request => $request, - response => HTTP::Response->new - ); - - $class->handler($lwp); - $connection->send_response( $lwp->response ); - - if ( $class->debug ) { - $class->log->info( sprintf( "Peer %s:%d",$connection->peerhost, $connection->peerport ) ); - } - - } - - $connection->close; - undef($connection); - } -} - -=back - =head1 SEE ALSO -L, L. +L, L, L. =head1 AUTHOR @@ -107,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;