Filter
2 years ago
ChunkStream.php
2 years ago
CompressStream.php
6 months ago
DechunkStream.php
2 years ago
DecompressStream.php
6 months ago
DeflateStream.php
6 months ago
FilteredStream.php
6 months ago
GzipDecodeStream.php
6 months ago
GzipEncodeStream.php
6 months ago
InflateStream.php
6 months ago
ChunkStream.php
40 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AmeliaHttp\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 | protected function readFilter() |
| 16 | { |
| 17 | return 'chunk'; |
| 18 | } |
| 19 | |
| 20 | /** |
| 21 | * {@inheritdoc} |
| 22 | */ |
| 23 | protected function writeFilter() |
| 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 |