mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Merge pull request #4106 from cakephp/header-exception
Raise exceptions when headers have been sent
This commit is contained in:
commit
8b1a65f8b9
1 changed files with 10 additions and 6 deletions
|
@ -517,16 +517,20 @@ 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 (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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a content string to the client.
|
||||
|
|
Loading…
Add table
Reference in a new issue