Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 97591c1

Browse filesBrowse files
GromNaNfabpot
authored andcommitted
Check headers sent before sending PHP response
If the response contents has been sent before an error occurs, PHP triggers the warning "Cannot modify header information - headers already sent" This change ensure that the error message is echoed, while it's impossible to change the HTTP status code and headers.
1 parent 26d4db3 commit 97591c1
Copy full SHA for 97591c1

File tree

Expand file treeCollapse file tree

1 file changed

+5
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-3
lines changed

‎src/Symfony/Component/Debug/ExceptionHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Debug/ExceptionHandler.php
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,11 @@ public function sendPhpResponse($exception)
9191
$exception = FlattenException::create($exception);
9292
}
9393

94-
header(sprintf('HTTP/1.0 %s', $exception->getStatusCode()));
95-
foreach ($exception->getHeaders() as $name => $value) {
96-
header($name.': '.$value, false);
94+
if (!headers_sent()) {
95+
header(sprintf('HTTP/1.0 %s', $exception->getStatusCode()));
96+
foreach ($exception->getHeaders() as $name => $value) {
97+
header($name.': '.$value, false);
98+
}
9799
}
98100

99101
echo $this->decorate($this->getContent($exception), $this->getStylesheet($exception));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.