-
Notifications
You must be signed in to change notification settings - Fork 35
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for figuring this out! I have two related coding suggestions.
Co-authored-by: Dan Halbert <halbert@halwitz.org>
Co-authored-by: Dan Halbert <halbert@halwitz.org>
@@ -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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Updating https://github.com/adafruit/Adafruit_CircuitPython_Thermistor to 3.4.4 from 3.4.3: > Merge pull request adafruit/Adafruit_CircuitPython_Thermistor#20 from tcfranks/main Updating https://github.com/adafruit/Adafruit_CircuitPython_Requests to 1.12.4 from 1.12.2: > Merge pull request adafruit/Adafruit_CircuitPython_Requests#111 from klocs/throw_away_cleanup > Merge pull request adafruit/Adafruit_CircuitPython_Requests#110 from klocs/chunked_redirect_bug
I found that
Reponse._throw_away()
worked fine unless the bytes returned from_recv_into()
wasn't the full size of the throw away buffer. Simple fix once I figured out what was happening. Also including a unit test the reproduces the problem.