Fix host header on local tests
Christian Hansen [Thu, 31 Mar 2005 04:26:47 +0000 (04:26 +0000)]
lib/Catalyst/Engine.pm
lib/Catalyst/Engine/Test.pm

index bff8fef..876c822 100644 (file)
@@ -127,7 +127,9 @@ sub finalize {
     if ( my $location = $c->res->redirect ) {
         $c->log->debug(qq/Redirecting to "$location"/) if $c->debug;
         $c->res->headers->header( Location => $location );
+        $c->res->headers->remove_content_headers;
         $c->res->status(302);
+        return $c->finalize_headers;
     }
 
     if ( !$c->res->output || $#{ $c->error } >= 0 ) {
index 5ba8e4b..2436b7b 100644 (file)
@@ -73,7 +73,7 @@ sub finalize_headers {
             -secure  => $cookie->{secure} || 0
         );
 
-        $c->lwp->response->header( 'Set-Cookie' => $cookie->as_string );
+        $c->lwp->response->headers->push_header( 'Set-Cookie' => $cookie->as_string );
     }
 }
 
@@ -246,6 +246,9 @@ sub run {
         $request = HTTP::Request->new( 'GET', $request );
     }
 
+    my $host = sprintf( '%s:%d', $request->uri->host, $request->uri->port );
+    $request->header( 'Host' => $host );
+
     my $lwp = Catalyst::Engine::Test::LWP->new(
         address  => '127.0.0.1',
         hostname => 'localhost',