use strict;
use base 'Catalyst::Engine::Test';
-use IO::Socket qw(AF_INET);
+use IO::Socket qw(AF_INET SOCK_STREAM SOMAXCONN);
=head1 NAME
my $port = shift || 3000;
my $daemon = Catalyst::Engine::HTTP::Catalyst->new(
+ Listen => SOMAXCONN,
LocalPort => $port,
- ReuseAddr => 1
+ ReuseAddr => 1,
+ Type => SOCK_STREAM,
);
unless ($daemon) {
while ( my $connection = $daemon->accept ) {
+ $connection->timeout(5);
+
while ( my $request = $connection->get_request ) {
$request->uri->scheme('http'); # Force URI::http
$request->uri->port( $base->port );
my $lwp = Catalyst::Engine::Test::LWP->new(
- request => $request,
address => $connection->peerhost,
- hostname => gethostbyaddr( $connection->peeraddr, AF_INET )
+ 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;