1
0
mirror of https://github.com/danog/byte-stream.git synced 2024-11-30 04:19:23 +01:00
byte-stream/examples/gzip-decompress.php

20 lines
420 B
PHP
Raw Normal View History

2017-05-05 22:39:39 +02:00
<?php
use Amp\ByteStream\ZlibInputStream;
2017-05-05 22:39:39 +02:00
use Amp\Loop;
use function Amp\ByteStream\getStdin;
use function Amp\ByteStream\getStdout;
2017-05-05 22:39:39 +02:00
require __DIR__."/../vendor/autoload.php";
2017-05-05 22:39:39 +02:00
Loop::run(function () {
$stdin = getStdin();
$stdout = getStdout();
2017-05-05 22:39:39 +02:00
2017-05-25 17:51:25 +02:00
$gzin = new ZlibInputStream($stdin, ZLIB_ENCODING_GZIP);
2017-05-05 22:39:39 +02:00
while (($chunk = yield $gzin->read()) !== null) {
yield $stdout->write($chunk);
}
});