Skip to content

Commit 90257e5

Browse files
authored
Merge pull request #5680 from kenjis/fix-exceptionHandler-header
fix: do not call header() if headers have already been sent
2 parents ccd49e4 + e3d3b71 commit 90257e5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

system/Debug/Exceptions.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ public function exceptionHandler(Throwable $exception)
109109

110110
if (! is_cli()) {
111111
$this->response->setStatusCode($statusCode);
112-
header(sprintf('HTTP/%s %s %s', $this->request->getProtocolVersion(), $this->response->getStatusCode(), $this->response->getReasonPhrase()), true, $statusCode);
112+
if (! headers_sent()) {
113+
header(sprintf('HTTP/%s %s %s', $this->request->getProtocolVersion(), $this->response->getStatusCode(), $this->response->getReasonPhrase()), true, $statusCode);
114+
}
113115

114116
if (strpos($this->request->getHeaderLine('accept'), 'text/html') === false) {
115117
$this->respond(ENVIRONMENT === 'development' ? $this->collectVars($exception, $statusCode) : '', $statusCode)->send();

0 commit comments

Comments
 (0)