-
Notifications
You must be signed in to change notification settings - Fork 0
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
No means for retrieving response/body after InvalidArgumentException #349
Comments
If the server answers with a status code that is not supported by the RFC, then we cannot create a Response object, ie, there is no response. |
Agreed. |
@Nyholm @GrahamCampbell - While I agree with you that a Response cannot be created, perhaps there is something we can do in terms of an Exception response here. At the moment it's impossible to see the headers/body of the response (due to the status codes and/or headers being malformed). The body might be a challenge to handle properly given it's a stream, but dumping the headers into the exception I don't think is an unreasonable request, should they be available? I appreciate sticking to the RFC with this stance, but the web is an irregular environment and if you're in no control of the endpoint being requested it basically makes the library unusable for those use-cases where an irregular response is out of your control. For example: This could be updated to add some context of the request details that caused the exception - the header asserts do this already: Line 227 in 7858757
|
This PR is related: Nyholm/psr7#157 Please open an issue/pr on guzzle/psr7 about improving the exception message. |
@Nyholm: This confused me first, this is a fork of guzzle/psr7? |
Description
Currently guzzle will throw an
InvalidArgumentException
when the status code of an HTTP response is outside of allowed range.That exception comes without an instance to the response object, hence there is no way retrieving the response body.
How to reproduce
Perform a guzzle request and let it be answered with a status code that is outside of allowed range.
Possible Solution
Extend the InvalidArgumentException by a reference to the original, throwing response object.
Related
guzzle/guzzle#1105
The text was updated successfully, but these errors were encountered: