mirror of
https://github.com/danog/byte-stream.git
synced 2024-11-27 12:24:48 +01:00
20 lines
467 B
PHP
20 lines
467 B
PHP
<?php
|
|
|
|
use Amp\ByteStream\ResourceInputStream;
|
|
use Amp\ByteStream\ResourceOutputStream;
|
|
use Amp\ByteStream\ZlibInputStream;
|
|
use Amp\Loop;
|
|
|
|
require __DIR__ . "/../vendor/autoload.php";
|
|
|
|
Loop::run(function () {
|
|
$stdin = new ResourceInputStream(STDIN);
|
|
$stdout = new ResourceOutputStream(STDOUT);
|
|
|
|
$gzin = new ZlibInputStream($stdin, ZLIB_ENCODING_GZIP);
|
|
|
|
while (($chunk = yield $gzin->read()) !== null) {
|
|
yield $stdout->write($chunk);
|
|
}
|
|
});
|