Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when handling 404 responses with JSON content in body #133

Open
bc-ravijayaramappa opened this issue Apr 27, 2015 · 1 comment

Comments

@bc-ravijayaramappa
Copy link
Contributor

Connection.php L212
If the response body of a request with 404 status has JSON content, the library throws an exception instead of ClientError.

Cause: Connection::handleResponse() decodes the response body without checking the response status and then tries to create a ClientError object using the decoded response body object. ClientError is expecting a string as argument but gets an object instead and thus throws an Error

@Y0lk
Copy link
Contributor

Y0lk commented Jul 11, 2018

Wow this is old. I got the same issue (but with a different error). Whenever the body is not JSON and you're using JSON, it will pass an incorrect argument to ClientError and crash. This does not happen if you're using Xml, as the body is returned raw.

This could be easily fixed by calling json_decode after the status check. I can make a pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants