Skip to content

Commit

Permalink
Fix headers already sent error when setting status code in response
Browse files Browse the repository at this point in the history
  • Loading branch information
jreviews committed Dec 20, 2023
1 parent 5662a7e commit a7bef2c
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/yoyo/Services/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@ public function send(string $content = ''): string
header("$key: $value");
}

if ($this->statusCode == 204) {
http_response_code(204);
if (! headers_sent()) {
http_response_code($this->statusCode ?? 200);
}

http_response_code($this->statusCode ?? 200);

return $content ?: '';
}

Expand Down

0 comments on commit a7bef2c

Please sign in to comment.