return an error when there are insufficient bytes #6
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.
This aims to resolve #5. This could probably be cleaner and I'm not positive I'm missing certain scenarios but I have tested this in several integrations in addition to the tests added for this. I'm happy to make updates and/or add some additional scenarios to the tests.
This updates the state to additionally keep track of how much data was requested (
wants
), how much data has beenread
and thetotal
number of bytes that have gone through the states buffers. The idea, as mentioned in the comments fordidOverread
is to check if we're requesting bytes in excess of what is available, without breaking successive reads.I've verified this integrated with: