throw an Exception when header is already been sent

This commit is contained in:
Xinquan Zhu 2014-07-17 10:50:43 +09:00 committed by mark_story
parent 3c1d3ee461
commit 792c251890

View file

@ -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");
}
}
/**