Add a default body to redirect responses
Andy Grundman [Fri, 23 Feb 2007 23:38:46 +0000 (23:38 +0000)]
Changes
lib/Catalyst.pm

diff --git a/Changes b/Changes
index b9d4c15..32e9176 100644 (file)
--- a/Changes
+++ b/Changes
@@ -6,6 +6,7 @@ This file documents the revision history for Perl extension Catalyst.
         - Support restart_delay of 0 (for use in the POE engine).
         - Skip body processing if we don't have a Content-Length header.
           Results in about a 9% performance increase when handling GET/HEAD requests.
+        - Add a default body to redirect responses.
 
 5.7006   2006-11-03 14.18
         - Updated manifest
index e73e2c6..c4a2089 100644 (file)
@@ -1391,6 +1391,13 @@ sub finalize_headers {
     if ( my $location = $c->response->redirect ) {
         $c->log->debug(qq/Redirecting to "$location"/) if $c->debug;
         $c->response->header( Location => $location );
+        
+        if ( !$c->response->body ) {
+            # Add a default body if none is already present
+            $c->response->body(
+                "<p>This item has moved <a href=\"$location\">here</a>.</p>"
+            );
+        }
     }
 
     # Content-Length