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
Misleading IncompleteRead exception, if a HTTP response contains unexpected content
#3261
Labels
💰 Bounty $100
If you complete this issue we'll pay you $100 on OpenCollective!
Contributor Friendly ♥
Comments
|
@crazyscientist Thanks for reporting this. I would accept a fix that detects this situation and reraises as a |
crazyscientist
added a commit
to crazyscientist/urllib3
that referenced
this issue
Jan 9, 2024
`HTTPResponse._raw_read` raises `IncompleteRead` if the content length does not match the expected content length. For malformed responses (e.g. 204 response with content) the re-raised `ProtocolError` was a bit too unclear about the unexpected excess content being the reason for the exception. With this change, the exception points out, that the client is not dealing with a connection error but a protocol violation. Closes urllib3#3261
crazyscientist
added a commit
to crazyscientist/urllib3
that referenced
this issue
Jan 9, 2024
`HTTPResponse._raw_read` raises `IncompleteRead` if the content length does not match the expected content length. For malformed responses (e.g. 204 response with content) the re-raised `ProtocolError` was a bit too unclear about the unexpected excess content being the reason for the exception. With this change, the exception points out, that the client is not dealing with a connection error but a protocol violation. Closes urllib3#3261
crazyscientist
added a commit
to crazyscientist/urllib3
that referenced
this issue
Jan 9, 2024
`HTTPResponse._raw_read` raises `IncompleteRead` if the content length does not match the expected content length. For malformed responses (e.g. 204 response with content) the re-raised `ProtocolError` was a bit too unclear about the unexpected excess content being the reason for the exception. With this change, the exception points out, that the client is not dealing with a connection error but a protocol violation. Closes urllib3#3261
crazyscientist
added a commit
to crazyscientist/urllib3
that referenced
this issue
Jan 9, 2024
`HTTPResponse._raw_read` raises `IncompleteRead` if the content length does not match the expected content length. For malformed responses (e.g. 204 response with content) the re-raised `ProtocolError` was a bit too unclear about the unexpected excess content being the reason for the exception. With this change, the exception points out, that the client is not dealing with a connection error but a protocol violation. Closes urllib3#3261
crazyscientist
added a commit
to crazyscientist/urllib3
that referenced
this issue
Jan 10, 2024
`HTTPResponse._raw_read` raises `IncompleteRead` if the content length does not match the expected content length. For malformed responses (e.g. 204 response with content) the re-raised `ProtocolError` was a bit too unclear about the unexpected excess content being the reason for the exception. With this change, the exception points out, that the client is not dealing with a connection error but a protocol violation. Closes urllib3#3261
crazyscientist
added a commit
to crazyscientist/urllib3
that referenced
this issue
Feb 5, 2024
`HTTPResponse._raw_read` raises `IncompleteRead` if the content length does not match the expected content length. For malformed responses (e.g. 204 response with content) the re-raised `ProtocolError` was a bit too unclear about the unexpected excess content being the reason for the exception. With this change, the exception points out, that the client is not dealing with a connection error but a protocol violation. Closes urllib3#3261
|
@crazyscientist thanks for improving the error message, feel free to claim the $100 bounty from our OpenCollective |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
💰 Bounty $100
If you complete this issue we'll pay you $100 on OpenCollective!
Contributor Friendly ♥
Subject
When interacting with poorly implemented servers or when paying little attention during mocking of HTTP requests, one can be faced e.g. with a 204 response, which contains an unexpected body.
So far so bad. urllib3 only raises an
IncompleteReadexception, which provides no insight into the reason (e.g. a 204 response with body).Environment
Steps to Reproduce
Expected Behavior
If an empty response body is expected, the raised exception should complain about the presence of an unexpected body.
Also, the reason for expecting an empty body would be helpful and speed up debugging.
Actual Behavior
Instead,
IncompleteRead(16 bytes read, -16 more expected)is raised:The text was updated successfully, but these errors were encountered: