package Catalyst::Engine::Test;
use strict;
-use base 'Catalyst::Engine::LWP';
+use base 'Catalyst::Engine::HTTP::Base';
+
+use Catalyst::Utils;
=head1 NAME
=head1 OVERLOADED METHODS
-This class overloads some methods from C<Catalyst::Engine::LWP>.
+This class overloads some methods from C<Catalyst::Engine::HTTP::Base>.
=over 4
=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