1 | <?php |
||
2 | |||
3 | namespace Http\Message\Encoding\Filter; |
||
4 | |||
5 | /** |
||
6 | * Userland implementation of the chunk stream filter. |
||
7 | * |
||
8 | * @author Joel Wurtz <[email protected]> |
||
9 | */ |
||
10 | class Chunk extends \php_user_filter |
||
11 | { |
||
12 | /** |
||
13 | * {@inheritdoc} |
||
14 | */ |
||
15 | 2 | public function filter($in, $out, &$consumed, $closing) |
|
16 | { |
||
17 | 2 | while ($bucket = stream_bucket_make_writeable($in)) { |
|
18 | 2 | $lenbucket = stream_bucket_new($this->stream, dechex($bucket->datalen)."\r\n"); |
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
19 | 2 | stream_bucket_append($out, $lenbucket); |
|
20 | |||
21 | 2 | $consumed += $bucket->datalen; |
|
22 | 2 | stream_bucket_append($out, $bucket); |
|
23 | |||
24 | 2 | $lenbucket = stream_bucket_new($this->stream, "\r\n"); |
|
25 | 2 | stream_bucket_append($out, $lenbucket); |
|
26 | } |
||
27 | |||
28 | 2 | return PSFS_PASS_ON; |
|
29 | } |
||
30 | } |
||
31 |