1 <?php
2
3 namespace Http\Message\Encoding;
4
5 6 7 8 9
10 class ChunkStream extends FilteredStream
11 {
12 13 14
15 public function getReadFilter()
16 {
17 if (!array_key_exists('chunk', stream_get_filters())) {
18 stream_filter_register('chunk', 'Http\Message\Encoding\Filter\Chunk');
19 }
20
21 return 'chunk';
22 }
23
24 25 26
27 public function getWriteFilter()
28 {
29 return 'dechunk';
30 }
31
32 33 34
35 protected function fill()
36 {
37 parent::fill();
38
39 if ($this->stream->eof()) {
40 $this->buffer .= "0\r\n\r\n";
41 }
42 }
43 }
44