From bae276fde6ccc6dadd4c31573d8d324fe82d2a36 Mon Sep 17 00:00:00 2001 From: Pascal Bleser Date: Mon, 16 Nov 2026 12:01:55 +0100 Subject: [PATCH] test(acceptance): fail on responses that are cut off after their headers When the transfer of a response broke off after its headers, e.g. because the server aborted it, sendRequestOnce caught the exception and passed the incomplete response on as if it were complete. Tests then failed later, and misleadingly, e.g. with a JsonException on the cut-off body, or passed when they only checked the status code. Re-throw Guzzle's ResponseTransferException, so that such a test fails at the request, with the transfer error (e.g. cURL error 18). Refs #4008 Assisted-by: Claude Code:claude-opus-5-5 --- tests/acceptance/TestHelpers/HttpRequestHelper.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/acceptance/TestHelpers/HttpRequestHelper.php b/tests/acceptance/TestHelpers/HttpRequestHelper.php index 3033393e93..ceb9faafc8 100644 --- a/tests/acceptance/TestHelpers/HttpRequestHelper.php +++ b/tests/acceptance/TestHelpers/HttpRequestHelper.php @@ -25,6 +25,7 @@ use GuzzleHttp\Client; use GuzzleHttp\Cookie\CookieJar; use GuzzleHttp\Exception\GuzzleException; use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Exception\ResponseTransferException; use GuzzleHttp\Psr7\Request; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -176,11 +177,16 @@ class HttpRequestHelper { // The exceptions that might happen here include: // ConnectException - in that case there is no response. Don't catch the exception. + // ResponseTransferException - the transfer broke off after the response headers, + // e.g. because the server aborted the response. Its body is + // incomplete, so don't pass it back as if it were the response. // RequestException - if there is something in the response then pass it back. // Otherwise, re-throw the exception. // GuzzleException - something else unexpected happened. Don't catch the exception. try { $response = $client->send($request); + } catch (ResponseTransferException $ex) { + throw $ex; } catch (RequestException $ex) { $response = $ex->getResponse();