2 encoding stream brotli with explicit flush
6 class_exists("http\\Encoding\\Stream\\Enbrotli") or die("SKIP need brotli support");
12 $enc = new http\Encoding\Stream\Enbrotli;
13 $dec = new http\Encoding\Stream\Debrotli;
14 $file = file(__FILE__);
16 foreach ($file as $line) {
17 $data .= $dec->flush();
18 if (strlen($temp = $enc->update($line))) {
19 $data .= $dec->update($temp);
20 $data .= $dec->flush();
22 if (strlen($temp = $enc->flush())) {
23 $data .= $dec->update($temp);
24 $data .= $dec->flush();
27 if (strlen($temp = $enc->finish())) {
28 $data .= $dec->update($temp);
30 var_dump($enc->done());
31 $data .= $dec->finish();
32 var_dump($dec->done());
33 var_dump(implode("", $file) === $data);