From 91a9d06a7b2a1c8d32840df7f78a1a2362ffda80 Mon Sep 17 00:00:00 2001 From: Jorg Sowa Date: Sun, 29 Nov 2026 21:10:26 +0100 Subject: [PATCH] Fix intermittent curl test failures on FreeBSD The curl test server bound "localhost:0", which FreeBSD resolves to 127.0.0.1 only, while libcurl tries ::1 first. With nothing listening on [::1]:port, the kernel occasionally picks that same port as the local port and the socket connects to itself, so curl reads back its own request ("Received HTTP/0.9 when not allowed"). Bind to 127.0.0.1. --- ext/curl/tests/bug79033.phpt | 2 +- ext/curl/tests/server.inc | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ext/curl/tests/bug79033.phpt b/ext/curl/tests/bug79033.phpt index 6bd3331eb9ec..8c2a1b24fee6 100644 --- a/ext/curl/tests/bug79033.phpt +++ b/ext/curl/tests/bug79033.phpt @@ -22,7 +22,7 @@ string(%d) "array(0) { } " string(%d) "POST /get.inc?test=post HTTP/1.1 -Host: localhost:%d +Host: 127.0.0.1:%d Accept: */* Content-Length: 0 Content-Type: application/x-www-form-urlencoded diff --git a/ext/curl/tests/server.inc b/ext/curl/tests/server.inc index a7b177593db7..d7caf55670ba 100644 --- a/ext/curl/tests/server.inc +++ b/ext/curl/tests/server.inc @@ -4,7 +4,8 @@ function curl_cli_server_start() { $php_executable = getenv('TEST_PHP_EXECUTABLE') ?: PHP_BINARY; $doc_root = __DIR__; $router = "responder/get.inc"; - $cmd = [$php_executable, '-t', $doc_root, '-n', '-S', 'localhost:0', $router]; + // With "localhost", libcurl tries ::1 first, which can connect to itself when the server bound only 127.0.0.1. + $cmd = [$php_executable, '-t', $doc_root, '-n', '-S', '127.0.0.1:0', $router]; $descriptorspec = array( 0 => STDIN, 1 => STDOUT,