Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[HttpFoundation][Runtime] Add $flush parameter to Response::send() #52047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Symfony/Component/HttpFoundation/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ CHANGELOG
* Support root-level `Generator` in `StreamedJsonResponse`
* Add `UriSigner` from the HttpKernel component
* Add `partitioned` flag to `Cookie` (CHIPS Cookie)
* Add argument `bool $flush = true` to `Response::send()`

6.3
---
Expand Down
9 changes: 8 additions & 1 deletion src/Symfony/Component/HttpFoundation/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,13 +415,20 @@ public function sendContent(): static
/**
* Sends HTTP headers and content.
*
* @param bool $flush Whether output buffers should be flushed
*
* @return $this
*/
public function send(): static
public function send(/* bool $flush = true */): static
{
$this->sendHeaders();
$this->sendContent();

$flush = 1 <= \func_num_args() ? func_get_arg(0) : true;
if (!$flush) {
return $this;
}

if (\function_exists('fastcgi_finish_request')) {
fastcgi_finish_request();
} elseif (\function_exists('litespeed_finish_request')) {
Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/Runtime/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

6.4
---

* Add argument `bool $debug = false` to `HttpKernelRunner::__construct()`

5.4
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ class HttpKernelRunner implements RunnerInterface
public function __construct(
private readonly HttpKernelInterface $kernel,
private readonly Request $request,
private readonly bool $debug = false,
) {
}

public function run(): int
{
$response = $this->kernel->handle($this->request);
$response->send();
$response->send(!$this->debug);

if ($this->kernel instanceof TerminableInterface) {
$this->kernel->terminate($this->request, $response);
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Runtime/SymfonyRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function __construct(array $options = [])
public function getRunner(?object $application): RunnerInterface
{
if ($application instanceof HttpKernelInterface) {
return new HttpKernelRunner($application, Request::createFromGlobals());
return new HttpKernelRunner($application, Request::createFromGlobals(), $this->options['debug'] ?? false);
}

if ($application instanceof Response) {
Expand Down