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:
parent
4df0ee8233
commit
4bfa4f7e82
@ -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()
|
||||
|
@ -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
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user