From 792c251890d67ac643785def4ff5d8ee59318656 Mon Sep 17 00:00:00 2001 From: Xinquan Zhu Date: Thu, 17 Jul 2014 10:50:43 +0900 Subject: [PATCH] throw an Exception when header is already been sent --- lib/Cake/Network/CakeResponse.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Network/CakeResponse.php b/lib/Cake/Network/CakeResponse.php index 637299177..b5b0cd881 100644 --- a/lib/Cake/Network/CakeResponse.php +++ b/lib/Cake/Network/CakeResponse.php @@ -518,14 +518,16 @@ class CakeResponse { * @param string $value the header value * @return void */ - protected function _sendHeader($name, $value = null) { - if (!headers_sent()) { + protected function _sendHeader($name, $value = null) { + if (!headers_sent($filename, $linenum)) { if ($value === null) { header($name); } else { header("{$name}: {$value}"); } - } + } else { + throw new Exception("Headers already sent in $filename on line $linenum\n"); + } } /**