warn if modifying headers afer finalizing them
John Napiorkowski [Tue, 21 Jan 2014 23:41:39 +0000 (17:41 -0600)]
lib/Catalyst/Response.pm

index fa3b146..4d0e85a 100644 (file)
@@ -82,6 +82,15 @@ has _context => (
   clearer => '_clear_context',
 );
 
+before [qw(status headers content_encoding content_length content_type header)] => sub {
+  my $self = shift;
+
+  $self->_context->log->warn( 
+    "Useless setting a header value after finalize_headers called." .
+    " Not what you want." )
+      if ( $self->finalized_headers && @_ );
+};
+
 sub output { shift->body(@_) }
 
 sub code   { shift->status(@_) }