diff --git a/src/Stream.php b/src/Stream.php index 062e784..9f5677f 100644 --- a/src/Stream.php +++ b/src/Stream.php @@ -163,10 +163,6 @@ public function read($length) return fread($this->socket, $length); } - if ($this->getSize() < ($this->readed + $length)) { - throw new StreamException('Cannot read more than %s', $this->getSize() - $this->readed); - } - if ($this->getSize() === $this->readed) { return ''; } diff --git a/tests/StreamTest.php b/tests/StreamTest.php index 09bc7ee..9d5ea10 100644 --- a/tests/StreamTest.php +++ b/tests/StreamTest.php @@ -144,4 +144,14 @@ public function testClose() $this->assertFalse(is_resource($socket)); } + + public function testRead() + { + $stream = $this->createSocket("Body"); + + $this->assertEquals("Bod", $stream->read(3)); + $this->assertEquals("y", $stream->read(3)); + + $stream->close(); + } }