Skip to content

Commit baa4e56

Browse files
authored
Merge pull request #9 from maplephp/develop
Catch if headers already been sent
2 parents 0e4d040 + 13d3547 commit baa4e56

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/Handlers/AbstractHandler.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ final public function setSeverity(SeverityLevelPool $severity): self
171171
*/
172172
public function errorHandler(int $errNo, string $errStr, string $errFile, int $errLine = 0, array $context = []): bool
173173
{
174+
174175
if ($errNo & error_reporting()) {
175176
// Redirect to PHP error
176177
$redirectHandler = $this->redirectExceptionHandler($errNo, $errStr, $errFile, $errLine, $context);
@@ -262,13 +263,14 @@ public function shutdownHandler(): void
262263
protected function emitter(ExceptionItem $exceptionItem): void
263264
{
264265
//$this->cleanOutputBuffers();
265-
if (!headers_sent()) {
266-
header_remove('location');
267-
header('HTTP/1.1 500 Internal Server Error');
268-
}
269266
$response = $this->getHttp()->response()->withoutHeader('location');
270-
$response->createHeaders();
271-
$response->executeHeaders();
267+
268+
if (!headers_sent()) {
269+
header_remove('location');
270+
header('HTTP/1.1 500 Internal Server Error');
271+
$response->createHeaders();
272+
$response->executeHeaders();
273+
}
272274
$stream = $response->getBody();
273275

274276
if (is_callable($this->eventCallable)) {

0 commit comments

Comments
 (0)