Skip to content
Snippets Groups Projects
Commit 63c86798 authored by Maxime Veber's avatar Maxime Veber
Browse files

Flush headers (& fix test)

parent b7916d1e
Branches
No related tags found
No related merge requests found
Pipeline #620 canceled
......@@ -27,16 +27,18 @@ foreach ($_SERVER as $k => $v) {
$json = json_encode($vars, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
header('Content-Type: application/json', true);
switch ($vars['REQUEST_URI']) {
case '/long-to-execute':
flush();
sleep(5);
break;
case '/faster':
flush();
sleep(1);
break;
}
header('Content-Type: application/json', true);
echo $json;
......@@ -13,11 +13,12 @@ $response2 = $response = $client->request('GET', 'http://localhost:8001/faster')
$stream2 = $response2->toStream();
stream_set_blocking($stream2, 0);
$originalRead = [$stream1, $stream2];
$write = [];
$except = [];
do {
$read = [$stream1, $stream2];
$foo = stream_select($read, $write, $except, null, 0);
$read = $originalRead;
$foo = @stream_select($read, $write, $except, null, 0);
foreach ($read as $item) {
var_dump(stream_get_contents($item));
......@@ -25,8 +26,14 @@ do {
echo "Stream 1: \n";
var_dump(\feof($stream1));
if (\feof($stream1)) {
unset($originalRead[0]);
}
echo "Stream 2: \n";
var_dump(\feof($stream2));
} while (!\feof($stream1) && !\feof($stream2)); // while streams are not finished
if (\feof($stream1)) {
unset($originalRead[1]);
}
} while (!\feof($stream1) || !\feof($stream2)); // while streams are not finished
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment