X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine%2FTest.pm;h=a5f9ca472e27018a8fd5fecde75ad76bec4a6906;hb=66294129a6520edc031aa7a43fc9bdfce669af15;hp=fcd145e3718e86ae216c42a061846102409169e8;hpb=6f4e1683d466d0123cc7507b29a55b474ddca594;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine/Test.pm b/lib/Catalyst/Engine/Test.pm index fcd145e..a5f9ca4 100644 --- a/lib/Catalyst/Engine/Test.pm +++ b/lib/Catalyst/Engine/Test.pm @@ -1,7 +1,9 @@ package Catalyst::Engine::Test; use strict; -use base 'Catalyst::Engine::LWP'; +use base 'Catalyst::Engine::HTTP::Base'; + +use Catalyst::Utils; =head1 NAME @@ -29,7 +31,7 @@ This is the Catalyst engine specialized for testing. =head1 OVERLOADED METHODS -This class overloads some methods from C. +This class overloads some methods from C. =over 4 @@ -38,31 +40,26 @@ This class overloads some methods from C. =cut sub run { - my $class = shift; - my $request = shift || '/'; - - unless ( ref $request ) { - - my $uri = ( $request =~ m/http/i ) - ? URI->new($request) - : URI->new( 'http://localhost' . $request ); - - $request = $uri->canonical; - } + my ( $class, $request ) = @_; + + $request = Catalyst::Utils::request($request); - unless ( ref $request eq 'HTTP::Request' ) { - $request = HTTP::Request->new( 'GET', $request ); - } + $request->header( + 'Host' => sprintf( '%s:%d', $request->uri->host, $request->uri->port ) + ); - my $lwp = Catalyst::Engine::LWP::HTTP->new( - request => $request, + my $http = Catalyst::Engine::HTTP::Base::struct->new( address => '127.0.0.1', - hostname => 'localhost' + hostname => 'localhost', + request => $request, + response => HTTP::Response->new ); - $class->handler($lwp); + $http->response->date(time); + + $class->handler($http); - return $lwp->response; + return $http->response; } =back