[HttpClient] rewind streams created from strings
This commit is contained in:
parent
759f91c565
commit
33ed4e43c4
@ -100,7 +100,13 @@ final class HttplugClient implements HttpClient, RequestFactory, StreamFactory,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (\is_string($body ?? '')) {
|
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)) {
|
if (\is_resource($body)) {
|
||||||
|
@ -125,7 +125,13 @@ final class Psr18Client implements ClientInterface, RequestFactoryInterface, Str
|
|||||||
*/
|
*/
|
||||||
public function createStream(string $content = ''): StreamInterface
|
public function createStream(string $content = ''): StreamInterface
|
||||||
{
|
{
|
||||||
return $this->streamFactory->createStream($content);
|
$stream = $this->streamFactory->createStream($content);
|
||||||
|
|
||||||
|
if ($stream->isSeekable()) {
|
||||||
|
$stream->seek(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user