mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-09-05 07:16:27 +00:00
Attempt to fix timeout issue only occurring on ci
This commit is contained in:
@@ -1163,7 +1163,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
|
||||
$test = new Test();
|
||||
$test->curl->verbose();
|
||||
$test->curl->setTimeout(10);
|
||||
$test->server('timeout', 'GET', array(
|
||||
$test->server('timeout_legacy', 'GET', array(
|
||||
'seconds' => '5',
|
||||
));
|
||||
|
||||
|
||||
@@ -301,6 +301,32 @@ if ($test === 'http_basic_auth') {
|
||||
}
|
||||
}
|
||||
|
||||
echo '",' . "\n";
|
||||
echo ' "elapsed_seconds": "' . $elapsed . '",' . "\n";
|
||||
echo ' "server_port": "' . ((int)$_SERVER['SERVER_PORT']) . '",' . "\n";
|
||||
echo ' "server_start": "' . $server_start . '",' . "\n";
|
||||
echo ' "server_stop": "' . microtime(true) . '"' . "\n";
|
||||
echo '}' . "\n";
|
||||
exit;
|
||||
} elseif ($test === 'timeout_legacy') {
|
||||
// Use --no-buffer to view loading indicator (e.g.
|
||||
// curl --header "X-DEBUG-TEST: timeout_legacy" --include --no-buffer 127.0.0.1:8000/?seconds=3).
|
||||
header('Content-Type: application/json');
|
||||
$unsafe_seconds = (int)$_GET['seconds'];
|
||||
$start = microtime(true);
|
||||
echo '{' . "\n";
|
||||
echo ' "loading": "';
|
||||
|
||||
while (true) {
|
||||
echo '.';
|
||||
flush();
|
||||
sleep(1);
|
||||
$elapsed = microtime(true) - $start;
|
||||
if ($elapsed >= $unsafe_seconds) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
echo '",' . "\n";
|
||||
echo ' "elapsed_seconds": "' . $elapsed . '",' . "\n";
|
||||
echo ' "server_port": "' . ((int)$_SERVER['SERVER_PORT']) . '",' . "\n";
|
||||
|
||||
Reference in New Issue
Block a user