Skip to content

Fix handling of partial reads #102

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

Merged
merged 13 commits into from
Nov 13, 2018
Merged

Fix handling of partial reads #102

merged 13 commits into from
Nov 13, 2018

Conversation

mattsb42-aws
Copy link
Member

Issue #, if available: #24

Description of changes:
As noted in #24, the streaming_client classes have not historically correctly handled partial reads. Rather than accepting reads from the source stream that return fewer than the requested number of bytes, they assumed that this meant the source stream was complete. Per PEP 3116, this is incorrect: the stream should not be considered complete until no bytes are returned.

In order to simplify logic everywhere else, I ended up just adding a ProxyObject wrapper that keeps hitting the wrapped stream on read until it either gets the requested number of bytes or hits the end of the wrapped stream (as indicated by the stream returning nothing).

Tightly coupled with this was updating the fix made in #98 to correctly normalize to the bytes to read to -1 rather than None. This required a few small tweaks throughout streaming_client to correctly handle this new value.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mattsb42-aws mattsb42-aws requested a review from a team November 13, 2018 05:49
Copy link
Contributor

@karlw00t karlw00t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

We should avoid single char var names, but what's done is done.

@mattsb42-aws mattsb42-aws merged commit 1875c91 into aws:master Nov 13, 2018
@mattsb42-aws mattsb42-aws deleted the dev-24 branch November 13, 2018 22:55
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

Successfully merging this pull request may close these issues.

3 participants