Skip to content

Proposed fix for issue #103. Fixes an issue with _throw_away() and large chunked redirects. #110

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 7 commits into from
Jul 3, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions adafruit_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,8 @@ def _throw_away(self, nbytes: int) -> None:
to_read -= self._recv_into(buf, to_read)
remaining = nbytes % len_buf
if remaining:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking at it again, I think we can eliminate this if remaining: check also. What do you think?
I'm pretty new at working with github's UI so I'm not sure if I'm doing this right.

Copy link
Contributor

Choose a reason for hiding this comment

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

You're right, it's redundant! I made a release but go ahead and make another PR, and I'll make another reelase.

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe to_read and remaining could have the same name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. I'll work on it and see if it makes sense to combine the variables. It might be confusing though. I'll send another pull request in a bit, may not be today.

read = 0
while read < remaining:
read += self._recv_into(buf, remaining - read)
while remaining > 0:
remaining -= self._recv_into(buf, remaining)

def close(self) -> None:
"""Drain the remaining ESP socket buffers. We assume we already got what we wanted."""
Expand Down