From 55f2ccf8268bfae925319c35316bf1575d48f5cd Mon Sep 17 00:00:00 2001 From: Sjoerd Langkemper Date: Wed, 12 Aug 2026 12:17:45 +0000 Subject: [PATCH 1/3] ext/curl: speed up tests By waiting shorter for the server to be ready. In my setup, this takes it from 26 to 15 seconds for all curl tests. The first check for output on stderr takes approximately 10ms, so we wait 20ms to make sure its ready. The second check for the open port typically succeeds immediately, so move the sleep to after we have tried. --- ext/curl/tests/server.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/curl/tests/server.inc b/ext/curl/tests/server.inc index a7b177593db7..bf4b5ccd4e73 100644 --- a/ext/curl/tests/server.inc +++ b/ext/curl/tests/server.inc @@ -16,7 +16,7 @@ function curl_cli_server_start() { $bound = null; stream_set_blocking($pipes[2], false); for ($i = 0; $i < 60; $i++) { - usleep(50000); // 50ms per try + usleep(20000); // 20ms per try $status = proc_get_status($handle); if (empty($status['running'])) { echo "Server is not running\n"; @@ -45,7 +45,6 @@ function curl_cli_server_start() { // it might not be listening yet...need to wait until fsockopen() call returns $error = "Unable to connect to server\n"; for ($i=0; $i < 60; $i++) { - usleep(50000); // 50ms per try $status = proc_get_status($handle); $fp = @fsockopen("tcp://$bound"); // Failure, the server is no longer running @@ -58,6 +57,7 @@ function curl_cli_server_start() { $error = ''; break; } + usleep(20000); // 20ms per try } if ($fp) { @@ -79,7 +79,7 @@ function curl_cli_server_start() { if (!($status && $status['running'])) { break; } - usleep(50000); + usleep(20000); } }, $handle From 3ce3929a80be8f586e0845e9a3e7b0dcbdb12e29 Mon Sep 17 00:00:00 2001 From: Sjoerd Langkemper Date: Wed, 12 Aug 2026 12:44:45 +0000 Subject: [PATCH 2/3] ext/curl: smarter wait for server in test --- ext/curl/tests/curl_setopt_ssl.phpt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ext/curl/tests/curl_setopt_ssl.phpt b/ext/curl/tests/curl_setopt_ssl.phpt index f3b82e1756e3..f2aae42687ca 100644 --- a/ext/curl/tests/curl_setopt_ssl.phpt +++ b/ext/curl/tests/curl_setopt_ssl.phpt @@ -74,7 +74,10 @@ if ($process === false) { } try { // Give the server time to start - sleep(1); + for ($i = 0; $i < 100; $i++) { + if (@fsockopen('127.0.0.1', $port)) break; + usleep(20000); + } echo "case 1: client cert and key from string\n"; $ch = curl_init("https://127.0.0.1:$port/"); From 8fc637d775bfd5797eef5ebaef378d5ca876de19 Mon Sep 17 00:00:00 2001 From: Sjoerd Langkemper Date: Wed, 12 Aug 2026 12:47:49 +0000 Subject: [PATCH 3/3] ext/curl: disable expect/continue in tests Disable Expect: 100-continue to prevent libcurl's 1-second delay Expect 100-continue is a flow control mechanism that is not apparently not supported by the PHP development server. Curl waits one second for a 100-continue response and then continues anyway. https://everything.curl.dev/http/post/expect100.html > Unfortunately, lots of servers in the world do not properly support the Expect: header or do not handle it correctly, so curl only waits 1000 milliseconds for that first response before it continues anyway. > You can avoid the wait entirely by using -H Expect: to remove the header --- ext/curl/tests/bug54798-unix.phpt | 1 + ext/curl/tests/bug54798.phpt | 1 + ext/curl/tests/curl_pause_001.phpt | 1 + ext/curl/tests/curl_read_function_error_on_int.phpt | 3 ++- ext/curl/tests/curl_readfunc_abort.phpt | 1 + ext/curl/tests/curl_readfunction_throws_abort.phpt | 1 + 6 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ext/curl/tests/bug54798-unix.phpt b/ext/curl/tests/bug54798-unix.phpt index 6bbca3375ed5..a082d3733ae0 100644 --- a/ext/curl/tests/bug54798-unix.phpt +++ b/ext/curl/tests/bug54798-unix.phpt @@ -23,6 +23,7 @@ function checkForClosedFilePointer($host, $curl_option, $description) { if (CURLOPT_INFILE == $curl_option) { curl_setopt($ch, CURLOPT_UPLOAD, 1); + curl_setopt($ch, CURLOPT_HTTPHEADER, ['Expect:']); } curl_setopt($ch, $curl_option, $fp); diff --git a/ext/curl/tests/bug54798.phpt b/ext/curl/tests/bug54798.phpt index da38b72d775b..83cd0dedc58c 100644 --- a/ext/curl/tests/bug54798.phpt +++ b/ext/curl/tests/bug54798.phpt @@ -17,6 +17,7 @@ function checkForClosedFilePointer($host, $curl_option, $description) { if (CURLOPT_INFILE == $curl_option) { curl_setopt($ch, CURLOPT_UPLOAD, 1); + curl_setopt($ch, CURLOPT_HTTPHEADER, ['Expect:']); } curl_setopt($ch, $curl_option, $fp); diff --git a/ext/curl/tests/curl_pause_001.phpt b/ext/curl/tests/curl_pause_001.phpt index 1fce0dd4afa2..cb81d9f3f2b9 100644 --- a/ext/curl/tests/curl_pause_001.phpt +++ b/ext/curl/tests/curl_pause_001.phpt @@ -26,6 +26,7 @@ $inputHandle = fopen(__FILE__, 'r'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "{$host}/get.inc?test=input"); curl_setopt($ch, CURLOPT_UPLOAD, 1); +curl_setopt($ch, CURLOPT_HTTPHEADER, ['Expect:']); curl_setopt($ch, CURLOPT_READFUNCTION, new Input); curl_setopt($ch, CURLOPT_INFILE, $inputHandle); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); diff --git a/ext/curl/tests/curl_read_function_error_on_int.phpt b/ext/curl/tests/curl_read_function_error_on_int.phpt index 30ba97737727..e3023c45e2cd 100644 --- a/ext/curl/tests/curl_read_function_error_on_int.phpt +++ b/ext/curl/tests/curl_read_function_error_on_int.phpt @@ -14,7 +14,8 @@ include 'server.inc'; $host = curl_cli_server_start(); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "{$host}/get.php?test=post"); -curl_setopt($ch, CURLOPT_POST, ['f' => 'f']); +curl_setopt($ch, CURLOPT_POST, 1); +curl_setopt($ch, CURLOPT_HTTPHEADER, ['Expect:']); curl_setopt($ch, CURLOPT_TIMEOUT, 2); curl_setopt($ch, CURLOPT_READFUNCTION, "custom_readfunction" ); diff --git a/ext/curl/tests/curl_readfunc_abort.phpt b/ext/curl/tests/curl_readfunc_abort.phpt index 39103904fdc5..dfdcb800a2cc 100644 --- a/ext/curl/tests/curl_readfunc_abort.phpt +++ b/ext/curl/tests/curl_readfunc_abort.phpt @@ -10,6 +10,7 @@ $host = curl_cli_server_start(); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "{$host}/get.inc"); curl_setopt($ch, CURLOPT_POST, 1); +curl_setopt($ch, CURLOPT_HTTPHEADER, ['Expect:']); curl_setopt($ch, CURLOPT_READFUNCTION, function () { return CURL_READFUNC_ABORT; }); diff --git a/ext/curl/tests/curl_readfunction_throws_abort.phpt b/ext/curl/tests/curl_readfunction_throws_abort.phpt index a030f8c4f41e..2f2119d1c1b0 100644 --- a/ext/curl/tests/curl_readfunction_throws_abort.phpt +++ b/ext/curl/tests/curl_readfunction_throws_abort.phpt @@ -17,6 +17,7 @@ $ch = curl_init("{$host}/get.inc"); $file = new CURLFile(__DIR__ . '/curl_testdata1.txt'); curl_setopt($ch, CURLOPT_POST, 1); +curl_setopt($ch, CURLOPT_HTTPHEADER, ['Expect:']); echo "Test: read function throws exception\n"; curl_setopt($ch, CURLOPT_READFUNCTION,