xref: /PHP-8.3/ext/standard/tests/http/gh8641.phpt (revision d22d0e26)
1--TEST--
2GH-8641 ([Stream] STREAM_NOTIFY_COMPLETED over HTTP never emitted)
3--SKIPIF--
4<?php require 'server.inc'; http_server_skipif(); ?>
5--INI--
6allow_url_fopen=1
7--FILE--
8<?php
9require 'server.inc';
10
11function stream_notification_callback($notification_code, $severity, $message, $message_code, $bytes_transferred, $bytes_max)
12{
13    if ($notification_code === STREAM_NOTIFY_COMPLETED) {
14        echo $notification_code, ' ', $bytes_transferred, ' ', $bytes_max, PHP_EOL;
15    }
16}
17
18$ctx = stream_context_create();
19stream_context_set_params($ctx, array("notification" => "stream_notification_callback"));
20
21$responses = array(
22    "data://text/plain,HTTP/1.0 200 Ok\r\nContent-Length: 11\r\n\r\nHello world",
23);
24
25['pid' => $pid, 'uri' => $uri] = http_server($responses, $output);
26
27$f = file_get_contents($uri, 0, $ctx);
28
29http_server_kill($pid);
30var_dump($f);
31?>
32--EXPECTF--
338 11 11
34string(11) "Hello world"
35