Skip to content

Commit

Permalink
throw an Exception when header is already been sent
Browse files Browse the repository at this point in the history
  • Loading branch information
Xinquan Zhu authored and markstory committed Jul 29, 2014
1 parent 3c1d3ee commit 792c251
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/Cake/Network/CakeResponse.php
Expand Up @@ -518,14 +518,16 @@ protected function _setContentLength() {
* @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");
}
}

/**
Expand Down

0 comments on commit 792c251

Please sign in to comment.