Skip to content

Commit 497fdf2

Browse files
committed
[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
1 parent 646f1a0 commit 497fdf2

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎sapi/cli/tests/php_cli_server_expect_100_continue_iua.phpt‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,15 @@ if (PHP_OS_FAMILY === "Windows") die("skip SO_LINGER reset behaviour differs on
1111
include "php_cli_server.inc";
1212
$server = php_cli_server_start('echo "Hello world";', 'index.php', ['-d', 'ignore_user_abort=1']);
1313

14-
$fp = fsockopen(PHP_CLI_SERVER_HOSTNAME, PHP_CLI_SERVER_PORT);
14+
$fp = php_cli_server_connect();
15+
16+
$probe = php_cli_server_connect();
17+
fwrite($probe, "GET / HTTP/1.1\r\nConnection: close\r\n\r\n");
18+
while (!feof($probe)) {
19+
fgets($probe);
20+
}
21+
fclose($probe);
22+
1523
socket_set_option(socket_import_stream($fp), SOL_SOCKET, SO_LINGER, ['l_onoff' => 1, 'l_linger' => 0]);
1624
fwrite($fp, "POST / HTTP/1.1\r\nExpect: 100-continue\r\nContent-Length: 4\r\n\r\n");
1725
fclose($fp);

0 commit comments

Comments
 (0)