/** * Returns entry content * * @param io.archive.zip.ZipEntry entry * @return string */ protected function entryContent(ZipEntry $entry) { if ($entry->isDirectory()) { return NULL; } else { return (string) Streams::readAll($entry->getInputStream()); } }
/** * Retrieve string representation of part * * @return string */ public function getData() { $bytes = Streams::readAll($this->stream); // Create headers $headers = ''; $headers .= 'Content-Disposition: form-data; name="' . $this->name . '"; filename="' . $this->filename . '"' . self::CRLF; $headers .= 'Content-Type: ' . $this->contentType . self::CRLF; $headers .= 'Content-Length: ' . strlen($bytes) . self::CRLF; // Return payload return $headers . self::CRLF . $bytes; }
/** * Assertion helper * * @param io.archive.zip.ZipArchiveReader reader * @throws unittest.AssertionFailedError */ protected function assertSecuredEntriesIn($reader) { with($it = $reader->usingPassword('secret')->iterator()); $entry = $it->next(); $this->assertEquals('password.txt', $entry->getName()); $this->assertEquals(15, $entry->getSize()); $this->assertEquals('Secret contents', (string) Streams::readAll($entry->getInputStream())); $entry = $it->next(); $this->assertEquals('very.txt', $entry->getName()); $this->assertEquals(20, $entry->getSize()); $this->assertEquals('Very secret contents', (string) Streams::readAll($entry->getInputStream())); }
/** * Get data * * @return string */ public function content() { return Streams::readAll($this->input); }
public function readAll_propagates_exception() { Streams::readAll(new class implements InputStream { public function read($limit = 8192) { throw new IOException('FAIL'); } public function available() { return 1; } public function close() { } }); }
public function getInputStreams() { $this->conn->connect(); $dir = $this->conn->rootDir()->getDir('htdocs'); for ($i = 0; $i < 2; $i++) { try { $s = $dir->getFile('index.html')->getInputStream(); $this->assertEquals("<html/>\n", Streams::readAll($s)); } catch (IOException $e) { $this->fail('Round ' . ($i + 1), $e, NULL); } } }
public function readAllWithException() { Streams::readAll(newinstance('io.streams.InputStream', array(), '{ public function read($limit= 8192) { throw new IOException("FAIL"); } public function available() { return 1; } public function close() { } }')); }