Newer
Older
<?php
use Symfony\Component\HttpClient\NativeHttpClient;
require 'vendor/autoload.php';
$client = new NativeHttpClient();
$response1 = $client->request('GET', 'http://localhost:8000/long-to-execute');
$stream1 = $response1->toStream();
stream_set_blocking($stream1, 0);
$response2 = $response = $client->request('GET', 'http://localhost:8001/faster');
$stream2 = $response2->toStream();
stream_set_blocking($stream2, 0);
$read = $originalRead;
$foo = @stream_select($read, $write, $except, null, 0);
foreach ($read as $item) {
var_dump(stream_get_contents($item));
}
echo "Stream 1: \n";
var_dump(\feof($stream1));
if (\feof($stream1)) {
unset($originalRead[0]);
}
if (\feof($stream1)) {
unset($originalRead[1]);
}
} while (!\feof($stream1) || !\feof($stream2)); // while streams are not finished