1
0
mirror of https://github.com/guzzle/guzzle.git synced 2025-02-25 02:22:57 +01:00

Casting a stream to a string no longer starts from the beginning or resets the cursor position

This commit is contained in:
Michael Dowling 2013-09-08 21:07:08 -07:00
parent 4df0ee8233
commit 4bfa4f7e82
2 changed files with 4 additions and 12 deletions

View File

@ -115,15 +115,7 @@ class Stream implements StreamInterface
public function __toString()
{
if (!$this->isReadable() || (!$this->seekable && $this->eof())) {
return '';
}
$originalPos = $this->tell();
$body = stream_get_contents($this->stream, -1, 0);
$this->seek($originalPos);
return $body;
return stream_get_contents($this->stream, -1);
}
public function close()

View File

@ -8,10 +8,10 @@ namespace Guzzle\Stream;
interface StreamInterface
{
/**
* Convert the stream to a string by calling read until the end of the
* stream is reached.
* Reads the remainder of the stream from the current position until the
* end of the stream is reached.
*
* Warning: This will attempt to load the entire stream into memory.
* Warning: This could attempt to load a large amount of data into memory.
*
* @return string
*/