Fix ->finalize_headers getting called twice. RT#78090
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Engine.pm
index 181c5b0..c414896 100644 (file)
@@ -181,7 +181,6 @@ sub finalize_error {
         $name  = "<h1>$name</h1>";
 
         # Don't show context in the dump
-        $c->req->_clear_context;
         $c->res->_clear_context;
 
         # Don't show body parser in the dump
@@ -332,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;
 }
 
@@ -535,7 +534,7 @@ sub prepare_read {
 
 =head2 $self->prepare_request(@arguments)
 
-Sets up the PSGI environment in the Engine (just for back compat).
+Populate the context object from the request object.
 
 =cut
 
@@ -682,6 +681,7 @@ sub build_psgi_app {
 
         return sub {
             my ($respond) = @_;
+            confess("Did not get a response callback for writer, cannot continiue") unless $respond;
             $app->handle_request(env => $env, response_cb => $respond);
         };
     };