Merge pull request #4106 from cakephp/header-exception

Raise exceptions when headers have been sent
This commit is contained in:
José Lorenzo Rodríguez 2014-07-29 10:23:29 +02:00
commit 8b1a65f8b9

View file

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