Skip to content

[Stream] STREAM_NOTIFY_COMPLETED over HTTP never emitted #8641

Closed
@sfaut

Description

@sfaut

Description

The following code:

<?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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions