Closed tuupola closed 8 years ago
I am bit confused at the moment. Currently Curl and Guzzle clients behave in differently from React and Socket clients. With 4XX
and 5XX
responses call to $promise->wait()
with Curl and Guzzle clients throw an exception. React and Socket clients however do call $promise->then(...)
. See the gist above.
Which behaviour is considered correct?
After fixing #27 and your gist, new results are:
Guzzle async exception: Http\Client\Exception\HttpException
Guzzle sync exception: Http\Client\Exception\HttpException
CURL async exception: Http\Client\Common\Exception\ClientErrorException
CURL sync exception: Http\Client\Common\Exception\ClientErrorException
React async status: 404
React promise state: fulfilled
React sync exception: Http\Client\Common\Exception\ClientErrorException
Socket async exception: Http\Client\Common\Exception\ClientErrorException
Socket sync exception: Http\Client\Common\Exception\ClientErrorException
I think this could be closed.
On 4XX and 5XX response call to $promise->wait() Curl and Guzzle throw an exception.
Latest curl-client did not throws an exception in wait(). Can you show example code?
https://gist.github.com/tuupola/9862b11cc8fb6f7131545fffea900ee5
When using ErrorPlugin that is. Thanks for pointing out the mistake in the Gist. That was the main source of confusion. In the end it is only React which behaves differently.
Current dev-master of curl-client fixes the original problem for me. Thanks!
Fixed version released: https://github.com/php-http/curl-client/releases/tag/v1.6.1
When consuming API's the response body ofter includes additional information on
4XX
and5XX
errors. Currently bothsendRequest()
andwait()
throwRequestException
which does not allow accessing the response. This would be resolved by throwingHttpException
instead.Although I am not sure if
sendRequest()
actually ever throwsRequestException
even though code is there. Documentation says clients always return response andErrorPlugin
should be used to throw exceptions.Different clients seem to be behaving differently. For example React adapter returns response with 404 status instead of throwing.
https://gist.github.com/tuupola/9862b11cc8fb6f7131545fffea900ee5