Merge branch 'master' into phpng
[m6w6/ext-http] / tests / encstream004.phpt
1 --TEST--
2 encoding stream chunked flush
3 --SKIPIF--
4 <?php
5 include "skipif.inc";
6 ?>
7 --FILE--
8 <?php
9 echo "Test\n";
10
11 $dech = new http\Encoding\Stream\Dechunk(http\Encoding\Stream::FLUSH_FULL);
12 $file = file(__FILE__);
13 $data = "";
14 foreach ($file as $i => $line) {
15 $dech = clone $dech;
16 if ($i % 2) {
17 $data .= $dech->update(sprintf("%lx\r\n%s\r\n", strlen($line), $line));
18 } else {
19 $data .= $dech->update(sprintf("%lx\r\n", strlen($line)));
20 $data .= $dech->flush();
21 $data .= $dech->update($line);
22 $data .= $dech->flush();
23 $data .= $dech->update("\r\n");
24 }
25 $dech->flush();
26 $dech->done() and printf("uh-oh done() reported true!\n");
27 }
28 $data .= $dech->update("0\r\n");
29 var_dump($dech->done());
30 $data .= $dech->finish();
31 var_dump(implode("", $file) === $data);
32 ?>
33 DONE
34 --EXPECT--
35 Test
36 bool(true)
37 bool(true)
38 DONE