Applied wdh's fixed exec call to work on FreeBSD
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Engine / Test.pm
index 5dd0523..452cc2d 100644 (file)
@@ -2,7 +2,7 @@ package Catalyst::Engine::Test;
 
 use strict;
 use base 'Catalyst::Engine::CGI';
-use HTTP::Request;
+use Catalyst::Utils;
 use HTTP::Response;
 use HTTP::Status;
 use NEXT;
@@ -58,18 +58,7 @@ sub finalize_headers {
 sub run {
     my ( $self, $class, $request ) = @_;
 
-    # Construct request
-    unless ( ref $request ) {
-        if ( $request =~ m/http/i ) {
-            $request = URI->new($request)->canonical;
-        }
-        else {
-            $request = URI->new( 'http://localhost' . $request )->canonical;
-        }
-    }
-    unless ( ref $request eq 'HTTP::Request' ) {
-        $request = HTTP::Request->new( 'GET', $request );
-    }
+    $request = Catalyst::Utils::request($request);
 
     $request->header(
         'Host' => sprintf( '%s:%d', $request->uri->host, $request->uri->port )
@@ -77,10 +66,10 @@ sub run {
 
     # We emulate CGI
     local %ENV = (
-        PATH_INFO    => $request->uri->path  || '',
-        QUERY_STRING => $request->uri->query || '',
-        REMOTE_ADDR  => '127.0.0.1',
-        REMOTE_HOST  => 'localhost',
+        PATH_INFO       => $request->uri->path  || '',
+        QUERY_STRING    => $request->uri->query || '',
+        REMOTE_ADDR     => '127.0.0.1',
+        REMOTE_HOST     => 'localhost',
         REQUEST_METHOD  => $request->method,
         SERVER_NAME     => 'localhost',
         SERVER_PORT     => $request->uri->port,