You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
When calling toArray() on a response with an empty body, a TransportException is thrown. A TransportException should be thrown on network errors. However, responses with empty body might be completely valid. In that case, toArray() should throw JsonException (or other exception that implements DecodingExceptionInterface) should be thrown, because the reponse body does not contain valid JSON.
How to reproduce
$httpClient = HttpClient::create();
$response = $httpClient->request('GET', 'https://httpbin.org/status/201');
$response->toArray(); // throws TransportException with message 'Response body is empty.'
Possible Solution
Throw a JsonException instead of a TransportException when response body is empty.