-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathChunk.php
More file actions
29 lines (24 loc) · 832 Bytes
/
Chunk.php
File metadata and controls
29 lines (24 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
namespace Http\Message\Encoding\Filter;
/**
* Userland implementation of the chunk stream filter.
*
* @author Joel Wurtz <joel.wurtz@gmail.com>
*/
class Chunk extends \php_user_filter
{
public function filter($in, $out, &$consumed, $closing): int
{
while ($bucket = stream_bucket_make_writeable($in)) {
/* @phpstan-ignore argument.type */
$lenbucket = stream_bucket_new($this->stream, dechex($bucket->datalen)."\r\n");
stream_bucket_append($out, $lenbucket);
$consumed += $bucket->datalen;
stream_bucket_append($out, $bucket);
/* @phpstan-ignore argument.type */
$lenbucket = stream_bucket_new($this->stream, "\r\n");
stream_bucket_append($out, $lenbucket);
}
return PSFS_PASS_ON;
}
}