Skip to content

Commit

Permalink
[11.x] Fixes Illuminate\Http\Response to output empty string if `$c…
Browse files Browse the repository at this point in the history
…ontent` is set to `null` (#53872)

* [11.x] Fixes `Illuminate\Http\Response` to output empty string if
`$content` is set to `null`

1. Symfony set the content to `null` for `response()->noContent()` https://github.com/symfony/http-foundation/blob/e88a66c3997859532bc2ddd6dd8f35aba2711744/Response.php#L246-L249
2. This cause issue with PSR-7 HTTP Stream in Octane

fixed laravel/octane#972

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* Update Response.php

* Update Response.php

---------

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
crynobone and taylorotwell authored Dec 20, 2024
1 parent 0c6aa4b commit 620f717
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Illuminate/Http/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ public function __construct($content = '', $status = 200, array $headers = [])
$this->setProtocolVersion('1.0');
}

/**
* Get the response content.
*/
#[\Override]
public function getContent(): string|false
{
return transform(parent::getContent(), fn ($content) => $content, '');
}

/**
* Set the content on the response.
*
Expand Down

0 comments on commit 620f717

Please sign in to comment.