[php-src] Issue #8641: [Stream] STREAM_NOTIFY_COMPLETED over HTTP never emitted
| From: | sfaut | Date: | Fri, 27 May 2022 10:55:18 +0000 |
| Subject: | [php-src] Issue #8641: [Stream] STREAM_NOTIFY_COMPLETED over HTTP never emitted | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-241602@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/8641
Author: sfaut
### Description
The following code:
```php
<?php
function progress($notification_code, $severity, $message, $message_code, $bytes_transferred,
$bytes_maximum)
{
printf(
"%d\t%s\t%d\t%d\r\n",
$notification_code,
$notification_code == STREAM_NOTIFY_COMPLETED ? 'T' : 'F',
$bytes_transferred, $bytes_maximum,
);
};
$context = stream_context_create();
stream_context_set_params($context, ['notification' => 'progress']);
$stream_source = fopen('https://datasets.imdbws.com/title.ratings.tsv.gz',
'r', false, $context); // 6 MB file
$stream_destination = fopen('title.ratings.tsv.gz', 'w');
stream_copy_to_stream($stream_source, $stream_destination);
```
Resulted in this output:
```
2 F 0 0
4 F 0 0
5 F 0 6223383
7 F 0 6223383
7 F 8192 6223383
7 F 16384 6223383
7 F 24576 6223383
...
7 F 6207960 6223383
7 F 6216152 6223383
7 F 6223383 6223383
```
But I expected this output instead:
```
2 F 0 0
4 F 0 0
5 F 0 6223383
7 F 0 6223383
7 F 8192 6223383
7 F 16384 6223383
7 F 24576 6223383
...
7 F 6207960 6223383
7 F 6216152 6223383
8 T 6223383 6223383
```
With the last $notification_code = 8 as "STREAM_NOTIFY_COMPLETED".
Note that the last row has not always $bytes_transferred == $bytes_maximum
Thx :)
### PHP Version
PHP 8.1.6
### Operating System
Windows 10