diff --git a/lib/Cake/Network/CakeResponse.php b/lib/Cake/Network/CakeResponse.php index 637299177..b528ed28c 100644 --- a/lib/Cake/Network/CakeResponse.php +++ b/lib/Cake/Network/CakeResponse.php @@ -517,14 +517,18 @@ class CakeResponse { * @param string $name the header name * @param string $value the header value * @return void + * @throws CakeException When headers have already been sent */ protected function _sendHeader($name, $value = null) { - if (!headers_sent()) { - if ($value === null) { - header($name); - } else { - header("{$name}: {$value}"); - } + if (headers_sent($filename, $linenum)) { + throw new CakeException( + __d('cake_dev', 'Headers already sent in %d on line %s', $linenum, $filename) + ); + } + if ($value === null) { + header($name); + } else { + header("{$name}: {$value}"); } }