Fix ->finalize_headers getting called twice. RT#78090
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Engine.pm
index daf53d1..c414896 100644 (file)
@@ -180,6 +180,9 @@ sub finalize_error {
         $title = $name = "$name on Catalyst $Catalyst::VERSION";
         $name  = "<h1>$name</h1>";
 
+        # Don't show context in the dump
+        $c->res->_clear_context;
+
         # Don't show body parser in the dump
         $c->req->_clear_body;
 
@@ -328,7 +331,7 @@ Allows engines to write headers to response
 sub finalize_headers {
     my ($self, $ctx) = @_;
 
-    $ctx->response->finalize_headers;
+    $ctx->finalize_headers unless $ctx->response->finalized_headers;
     return;
 }