Commit 497fdf254e4 for php
commit 497fdf254e441fbfdd2135fa9bcfb370cbf0244d
Author: David Carlier <devnexen@gmail.com>
Date: Tue Sep 22 11:30:05 2026 +0100
[skip ci] sapi/cli: Wait for the connection in Expect 100-continue abort test
The test resets the connection as soon as it is opened, so the reset could
reach the server while the connection was still in the listen backlog. The
server then never saw the request and the expected error was never logged.
Complete a request on a second connection first: the accept queue is FIFO,
so a response on the later connection means the earlier one has been
accepted, and the reset is guaranteed to hit an established connection.
Close GH-23841
diff --git a/sapi/cli/tests/php_cli_server_expect_100_continue_iua.phpt b/sapi/cli/tests/php_cli_server_expect_100_continue_iua.phpt
index c792630a930..cf2a40a339a 100644
--- a/sapi/cli/tests/php_cli_server_expect_100_continue_iua.phpt
+++ b/sapi/cli/tests/php_cli_server_expect_100_continue_iua.phpt
@@ -11,7 +11,15 @@
include "php_cli_server.inc";
$server = php_cli_server_start('echo "Hello world";', 'index.php', ['-d', 'ignore_user_abort=1']);
-$fp = fsockopen(PHP_CLI_SERVER_HOSTNAME, PHP_CLI_SERVER_PORT);
+$fp = php_cli_server_connect();
+
+$probe = php_cli_server_connect();
+fwrite($probe, "GET / HTTP/1.1\r\nConnection: close\r\n\r\n");
+while (!feof($probe)) {
+ fgets($probe);
+}
+fclose($probe);
+
socket_set_option(socket_import_stream($fp), SOL_SOCKET, SO_LINGER, ['l_onoff' => 1, 'l_linger' => 0]);
fwrite($fp, "POST / HTTP/1.1\r\nExpect: 100-continue\r\nContent-Length: 4\r\n\r\n");
fclose($fp);