1 <?php
2
3 namespace Http\Message\Encoding;
4
5 /**
6 * Transform a regular stream into a chunked one.
7 *
8 * @author Joel Wurtz <joel.wurtz@gmail.com>
9 */
10 class ChunkStream extends FilteredStream
11 {
12 /**
13 * {@inheritdoc}
14 */
15 public function getReadFilter()
16 {
17 return 'chunk';
18 }
19
20 /**
21 * {@inheritdoc}
22 */
23 public function getWriteFilter()
24 {
25 return 'dechunk';
26 }
27
28 /**
29 * {@inheritdoc}
30 */
31 protected function fill()
32 {
33 parent::fill();
34
35 if ($this->stream->eof()) {
36 $this->buffer .= "0\r\n\r\n";
37 }
38 }
39 }
40