diff --git a/typo3/sysext/core/Classes/Http/Request.php b/typo3/sysext/core/Classes/Http/Request.php index 47ac172bacf92e42b8838e580eef903858a0b8fb..09f13dc81c22d18cd66e8dc75136ef07e237ae8b 100644 --- a/typo3/sysext/core/Classes/Http/Request.php +++ b/typo3/sysext/core/Classes/Http/Request.php @@ -96,7 +96,7 @@ class Request extends Message implements RequestInterface $this->body = $body; } else { $this->body = match (get_debug_type($body)) { - 'string', 'resource' => new Stream($body), + 'string', 'resource (stream)' => new Stream($body), 'null' => null, default => throw new \InvalidArgumentException('Body must be a string stream resource identifier, a stream resource, or a StreamInterface instance', 1436717271), }; diff --git a/typo3/sysext/core/Tests/Unit/Http/RequestTest.php b/typo3/sysext/core/Tests/Unit/Http/RequestTest.php index aabe93cedc2ed4c0213b1fe255bd2f00e55e04a6..26a85b168f1f5bf821abe2c6196cd64b19616439 100644 --- a/typo3/sysext/core/Tests/Unit/Http/RequestTest.php +++ b/typo3/sysext/core/Tests/Unit/Http/RequestTest.php @@ -17,6 +17,7 @@ declare(strict_types=1); namespace TYPO3\CMS\Core\Tests\Unit\Http; +use Psr\Http\Message\StreamInterface; use TYPO3\CMS\Core\Http\Request; use TYPO3\CMS\Core\Http\Stream; use TYPO3\CMS\Core\Http\Uri; @@ -128,6 +129,26 @@ final class RequestTest extends UnitTestCase new Request(null, 'GET', $body); } + public static function validRequestBodyDataProvider(): array + { + return [ + 'stringResourceIdentifier' => ['php://input'], + 'streamResource' => [fopen('php://memory', 'r')], + 'streamInterface' => [new Stream(fopen('php://memory', 'r'))], + 'null' => [null], + ]; + } + + /** + * @param resource|StreamInterface|string|null $body + * @dataProvider validRequestBodyDataProvider + * @test + */ + public function constructorDoesNotRaiseExceptionForValidBody($body): void + { + new Request(null, 'GET', $body); + } + /** * @test */