X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine%2FHTTP.pm;h=0d734567e2fd471a512c4e16b16f18a42076a56f;hb=15b7268ed273e75a0be3a97e8a89caf2414200f2;hp=37be240fb37d928670ad76490fe036c87726a0d0;hpb=03978da924d05019d7c6e27cb785cab28addbe67;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine/HTTP.pm b/lib/Catalyst/Engine/HTTP.pm index 37be240..0d73456 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 @@ -60,20 +60,24 @@ sub run { 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->host( $request->header('Host') || $base->host ); $request->uri->port( $base->port ); - my $lwp = Catalyst::Engine::Test::LWP->new( - request => $request, + my $http = Catalyst::Engine::Test::HTTP->new( 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 ); + $class->handler($http); + $connection->send_response( $http->response ); + } $connection->close;