From 4bfa4f7e82a62fef8000379a8c5ceba6c1c713dc Mon Sep 17 00:00:00 2001 From: Michael Dowling Date: Sun, 8 Sep 2013 21:07:08 -0700 Subject: [PATCH] Casting a stream to a string no longer starts from the beginning or resets the cursor position --- src/Guzzle/Stream/Stream.php | 10 +--------- src/Guzzle/Stream/StreamInterface.php | 6 +++--- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/Guzzle/Stream/Stream.php b/src/Guzzle/Stream/Stream.php index c1c7d6ca..d60462d8 100644 --- a/src/Guzzle/Stream/Stream.php +++ b/src/Guzzle/Stream/Stream.php @@ -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() diff --git a/src/Guzzle/Stream/StreamInterface.php b/src/Guzzle/Stream/StreamInterface.php index 0ffb3402..db6ed137 100644 --- a/src/Guzzle/Stream/StreamInterface.php +++ b/src/Guzzle/Stream/StreamInterface.php @@ -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 */