Skip to content

Commit 620f717

Browse files
[11.x] Fixes Illuminate\Http\Response to output empty string if $content 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 <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * Update Response.php * Update Response.php --------- Signed-off-by: Mior Muhammad Zaki <[email protected]> Co-authored-by: Taylor Otwell <[email protected]>
1 parent 0c6aa4b commit 620f717

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Illuminate/Http/Response.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ public function __construct($content = '', $status = 200, array $headers = [])
3737
$this->setProtocolVersion('1.0');
3838
}
3939

40+
/**
41+
* Get the response content.
42+
*/
43+
#[\Override]
44+
public function getContent(): string|false
45+
{
46+
return transform(parent::getContent(), fn ($content) => $content, '');
47+
}
48+
4049
/**
4150
* Set the content on the response.
4251
*

0 commit comments

Comments
 (0)