-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement GH-8641: STREAM_NOTIFY_COMPLETED over HTTP never emitted
This adds support for the completed event. Since the read handler could be entered twice towards the end of the stream we remember what the eof flag was before reading so we can emit the completed event when the flag changes to true. Closes GH-10505.
- Loading branch information
Showing
5 changed files
with
78 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--TEST-- | ||
GH-8641 ([Stream] STREAM_NOTIFY_COMPLETED over HTTP never emitted) | ||
--SKIPIF-- | ||
<?php require 'server.inc'; http_server_skipif(); ?> | ||
--INI-- | ||
allow_url_fopen=1 | ||
--FILE-- | ||
<?php | ||
require 'server.inc'; | ||
|
||
function stream_notification_callback($notification_code, $severity, $message, $message_code, $bytes_transferred, $bytes_max) | ||
{ | ||
if ($notification_code === STREAM_NOTIFY_COMPLETED) { | ||
echo $notification_code, ' ', $bytes_transferred, ' ', $bytes_max, PHP_EOL; | ||
} | ||
} | ||
|
||
$ctx = stream_context_create(); | ||
stream_context_set_params($ctx, array("notification" => "stream_notification_callback")); | ||
|
||
$responses = array( | ||
"data://text/plain,HTTP/1.0 200 Ok\r\nContent-Length: 11\r\n\r\nHello world", | ||
); | ||
|
||
['pid' => $pid, 'uri' => $uri] = http_server($responses, $output); | ||
|
||
$f = file_get_contents($uri, 0, $ctx); | ||
|
||
http_server_kill($pid); | ||
var_dump($f); | ||
?> | ||
--EXPECTF-- | ||
8 11 11 | ||
string(11) "Hello world" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters