Issues with some response codes from Symfony. #1620
-
|
Tested it with alpine and debian versions to remove any musl related issues. I have no idea why first request works, the only change I make is the change of the status code from 201 to 204 and then second response makes 0 sense... No Symfony headers and 200 response code, no content either. In the frankenphp logs I get: Which means that for some reason the headers are already send before that. But nothing changed except the response code... I'm moving from Caddy + PHP-FPM to Franken and suddenly half of the project is not working... Narrowed it down to this status code problem, but no amount of debug logs (on php and franken/caddy side) and step-debugging on PHP side solves the issue. I'm using franken classic mode, no worker mode to eliminate any issues from state not being cleared in memory. Even in the Symfony profiler: Any ideas? EDIT: Isolated the issue to the flush() function on PHP level (which is used in Symfony here: https://github.com/symfony/runtime/blob/fda552ee63dce9f3365f9c397efe7a80c8abac0a/Runner/Symfony/HttpKernelRunner.php#L46). Removing this line fixes the issue. Now the question is why this doesn't return the correct status code and headers: <?php
header('Content-Type: application/json');
header('HTTP/1.1 204 No Content', true, 204);
echo '{"status": "test"}';
flush();By removing flush - everything works as expected. <?php
header('Content-Type: application/json');
header('HTTP/1.1 204 No Content', true, 204);
echo '{"status": "test"}';Here is a repo for reproducing the issue: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Well... it turns out that flush() just flushes the body; and doesn't flush any pending headers. |
Beta Was this translation helpful? Give feedback.







Created a PR to address it in #1622