-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Description
Symfony version(s) affected: 4.3
Description
http-client with Psr18Client implementation doesn't provide the right exception (when 400 or above code is returned for example).
"Psr\Http\Client\ClientExceptionInterface" is expected instead of "Symfony\Component\HttpClient\Exception\ClientExceptionInterface".
How to reproduce
Do a "sendRequest" with "Psr18Client" that returns 404.
Possible Solution
In Psr18Client::sendRequest, catch the Symfony exception to re-throw it in Psr exception ?
Additional context
The default Psr18Client constructor create a symfony HttpClient then the response is "CurlReponse" or "NativeResponse" with "ResponseTrait" inside.
The method "Symfony\Component\HttpClient\Response\ResponseTrait::checkStatusCode()" throws "Symfony\Component\HttpClient\Exception\ClientException".
This exception appends when "$response->getHeaders()" in "Psr18Client::sendRequest" is called (without disabling throw), a check is done in "Symfony\Component\HttpClient\Response\ResponseTrait::checkStatusCode()".