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
This commit is contained in:
Pascal Bleser committed 2026-11-16 12:01:55 +01:00
1 parent 2ff7018524
commit bae276fde6
1 file changed
+6
@@ -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();