Make default body reponses for 302s W3C compliant. RT#71237
Tomas Doran [Tue, 4 Oct 2011 23:24:03 +0000 (00:24 +0100)]
Changes
lib/Catalyst.pm
lib/Catalyst/Response.pm

diff --git a/Changes b/Changes
index c76cc9b..cc25e0b 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,9 @@
 # This file documents the revision history for Perl extension Catalyst.
 
+  Bug fixes:
+
+   - Make default body reponses for 302s W3C compliant. RT#71237
+
   Enhancements:
 
    - Set a matching Content-type for the redirect if Catalyst sets the
index 641c84e..6e9d63c 100644 (file)
@@ -1863,9 +1863,17 @@ sub finalize_headers {
 
         if ( !$response->has_body ) {
             # Add a default body if none is already present
-            $response->body(
-                qq{<html><body><p>This item has moved <a href="$location">here</a>.</p></body></html>}
-            );
+            $response->body(<<"EOF");
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"> 
+  <head>
+    <title>Moved</title>
+  </head>
+  <body>
+     <p>This item has moved <a href="$location">here</a>.</p>
+  </body>
+</html>
+EOF
             $response->content_type('text/html; charset=utf-8');
         }
     }
index 818ae86..834b349 100644 (file)
@@ -14,6 +14,7 @@ has status    => (is => 'rw', default => 200);
 has finalized_headers => (is => 'rw', default => 0);
 has headers   => (
   is      => 'rw',
+  isa => 'HTTP::Headers',
   handles => [qw(content_encoding content_length content_type header)],
   default => sub { HTTP::Headers->new() },
   required => 1,