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

Conversation

klocs
Copy link
Contributor

@klocs klocs commented Jul 3, 2022

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.

Copy link
Contributor

@dhalbert dhalbert left a 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.

klocs and others added 2 commits July 3, 2022 13:44
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:
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.

@dhalbert dhalbert merged commit 136f130 into adafruit:main Jul 3, 2022
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Jul 4, 2022
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
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.

Getting a request.py error in the code for the "MagTag Lists From Google Spreadsheets" tutorial
2 participants