From e3d3b71e6073d853674b49a7a2aa8f016b2fdaf5 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 12 Feb 2022 12:53:34 +0900 Subject: [PATCH] fix: do not call header() if headers have already been sent --- system/Debug/Exceptions.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/system/Debug/Exceptions.php b/system/Debug/Exceptions.php index a65be7a2ad2f..e8249271733a 100644 --- a/system/Debug/Exceptions.php +++ b/system/Debug/Exceptions.php @@ -109,7 +109,9 @@ public function exceptionHandler(Throwable $exception) if (! is_cli()) { $this->response->setStatusCode($statusCode); - header(sprintf('HTTP/%s %s %s', $this->request->getProtocolVersion(), $this->response->getStatusCode(), $this->response->getReasonPhrase()), true, $statusCode); + if (! headers_sent()) { + header(sprintf('HTTP/%s %s %s', $this->request->getProtocolVersion(), $this->response->getStatusCode(), $this->response->getReasonPhrase()), true, $statusCode); + } if (strpos($this->request->getHeaderLine('accept'), 'text/html') === false) { $this->respond(ENVIRONMENT === 'development' ? $this->collectVars($exception, $statusCode) : '', $statusCode)->send();