Looping and recursion tests plus a fix
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Engine.pm
index 0665265..963ac5a 100644 (file)
@@ -102,8 +102,9 @@ sub finalize_error {
               . '</code></p>'
         } @{ $c->error };
         $error ||= 'No output';
+        $error = qq{<pre wrap="">$error</pre>};
         $title = $name = "$name on Catalyst $Catalyst::VERSION";
-        $name = "<h1>$name</h1>";
+        $name  = "<h1>$name</h1>";
 
         # Don't show context in the dump
         delete $c->req->{_context};
@@ -127,7 +128,7 @@ sub finalize_error {
             push @infos, sprintf <<"EOF", $name, $value;
 <h2><a href="#" onclick="toggleDump('dump_$i'); return false">%s</a></h2>
 <div id="dump_$i">
-    <pre>%s</pre>
+    <pre wrap="">%s</pre>
 </div>
 EOF
             $i++;
@@ -141,12 +142,10 @@ EOF
 <pre>
 (en) Please come back later
 (de) Bitte versuchen sie es spaeter nocheinmal
-(nl) Gelieve te komen later terug
+(at) Konnten's bitt'schoen spaeter nochmal reinschauen
 (no) Vennligst prov igjen senere
-(fr) Veuillez revenir plus tard
-(es) Vuelto por favor mas adelante
-(pt) Voltado por favor mais tarde
-(it) Ritornato prego piĆ¹ successivamente
+(dk) Venligst prov igen senere
+(pl) Prosze sprobowac pozniej
 </pre>
 
         $name = '';
@@ -234,6 +233,15 @@ EOF
             font-size: medium;
             font-weight: normal;
         }
+        /* from http://users.tkk.fi/~tkarvine/linux/doc/pre-wrap/pre-wrap-css3-mozilla-opera-ie.html */
+        /* Browser specific (not valid) styles to make preformatted text wrap */
+        pre { 
+            white-space: pre-wrap;       /* css-3 */
+            white-space: -moz-pre-wrap;  /* Mozilla, since 1999 */
+            white-space: -pre-wrap;      /* Opera 4-6 */
+            white-space: -o-pre-wrap;    /* Opera 7 */
+            word-wrap: break-word;       /* Internet Explorer 5.5+ */
+        }
     </style>
 </head>
 <body>
@@ -245,6 +253,12 @@ EOF
 </body>
 </html>
 
+
+    # Trick IE
+    $c->res->{body} .= ( ' ' x 512 );
+
+    # Return 500
+    $c->res->status(500);
 }
 
 =head2 $self->finalize_headers($c)
@@ -298,6 +312,13 @@ sub prepare_body {
         while ( my $buffer = $self->read($c) ) {
             $c->prepare_body_chunk($buffer);
         }
+
+        # paranoia against wrong Content-Length header
+        my $remaining = $self->read_length - $self->read_position;
+        if ($remaining > 0) {
+            $self->finalize_read($c);
+            Catalyst::Exception->throw("Wrong Content-Length value: ". $self->read_length);
+        }
     }
 }