X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine%2FHTTP.pm;h=b0f10d929911e14e9f18afaf46849f6760b6be87;hb=b26df351ecca539ec3b1e3a6bd54db2736583195;hp=35c3c4468249b0054de896de2309cfd3d2f1eaf2;hpb=03742cea7daff59ed41786a519d8ff7b0be75aad;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine/HTTP.pm b/lib/Catalyst/Engine/HTTP.pm index 35c3c44..b0f10d9 100644 --- a/lib/Catalyst/Engine/HTTP.pm +++ b/lib/Catalyst/Engine/HTTP.pm @@ -3,7 +3,7 @@ package Catalyst::Engine::HTTP; use strict; use base 'Catalyst::Engine::Test'; -use IO::Socket qw(AF_INET SOCK_STREAM SOMAXCONN); +use IO::Socket qw(AF_INET INADDR_ANY SOCK_STREAM SOMAXCONN); =head1 NAME @@ -47,7 +47,6 @@ sub run { Listen => SOMAXCONN, LocalPort => $port, ReuseAddr => 1, - Timeout => .1, Type => SOCK_STREAM, ); @@ -59,24 +58,30 @@ sub run { printf( "You can connect to your server at %s\n", $base ); - while ( 1 ) { + while ( my $connection = $daemon->accept ) { - my $connection = $daemon->accept or next; + $connection->timeout(5); while ( my $request = $connection->get_request ) { $request->uri->scheme('http'); # Force URI::http - $request->uri->host( $base->host ); + $request->uri->host( $request->header('Host') || $base->host ); $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;