diff --git a/src/Symfony/Component/HttpClient/HttplugClient.php b/src/Symfony/Component/HttpClient/HttplugClient.php index 6c612ce13c..71eb5200ce 100644 --- a/src/Symfony/Component/HttpClient/HttplugClient.php +++ b/src/Symfony/Component/HttpClient/HttplugClient.php @@ -100,7 +100,13 @@ final class HttplugClient implements HttpClient, RequestFactory, StreamFactory, } if (\is_string($body ?? '')) { - return $this->client->createStream($body ?? ''); + $body = $this->client->createStream($body ?? ''); + + if ($body->isSeekable()) { + $body->seek(0); + } + + return $body; } if (\is_resource($body)) { diff --git a/src/Symfony/Component/HttpClient/Psr18Client.php b/src/Symfony/Component/HttpClient/Psr18Client.php index ee8c813b46..acc85b8ea2 100644 --- a/src/Symfony/Component/HttpClient/Psr18Client.php +++ b/src/Symfony/Component/HttpClient/Psr18Client.php @@ -125,7 +125,13 @@ final class Psr18Client implements ClientInterface, RequestFactoryInterface, Str */ public function createStream(string $content = ''): StreamInterface { - return $this->streamFactory->createStream($content); + $stream = $this->streamFactory->createStream($content); + + if ($stream->isSeekable()) { + $stream->seek(0); + } + + return $stream; } /**