report error on unexpected EOF for fixed length HTTP body#427
Merged
Conversation
Coverage Report for CI Build 502Coverage increased (+0.04%) to 77.566%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions1 previously-covered line in 1 file lost coverage.
Coverage Stats
💛 - Coveralls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, the HTTP body parser does not perform length validation for fixed length body (i.e.
Content-Length), this will result in unexpected EOF from the transport layer not being reported as error. This PR fixes the issue. The HTTP body will now raise@io.ReaderClosedon unexpected EOF for fixed length body.The fix reveal another bug in previous code base. For
HEADrequest, the response body is always empty, butContent-Lengthetc. can still be set to indicate what the client would get if aGETrequest is made. So for response toHEADrequest, we should ignoreContent-Lengthetc., but this logic was not implemented previously. Due to the lack of length validation, test for this behavior accidentally passed. This PR also fixes this problem: the response body to aHEADrequest is now always assumed to be empty, no matter what headers are set.