Skip to content
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

Fix CachedResposnse.read() and ClientResponse.read() consistency #279

Merged
merged 5 commits into from
Nov 7, 2024

Conversation

alessio-locatelli
Copy link
Collaborator

@alessio-locatelli alessio-locatelli commented Oct 7, 2024

Closes #289

Inconsistency

  • ClientResponse allows to call read() multiple times, returning a full content.

  • CachedResponse allows to call read() multiple times, but silently returns nothing on further calls.

@JWCook Would you mind sharing your viewpoint? If this behavior is intentional, I will update the test accordingly.


UPDATE 2024-10-30:
I do not know if anyone ever calls read() more than once, so you may want to keep this change unreleased for a while or create a pre-release.

@alessio-locatelli alessio-locatelli force-pushed the add_tests branch 2 times, most recently from 8ade452 to 4c2a522 Compare October 7, 2024 09:50
@alessio-locatelli alessio-locatelli self-assigned this Oct 7, 2024
@JWCook
Copy link
Member

JWCook commented Oct 29, 2024

You're correct. I must have done it that way because that's how streaming responses behave in requests, but we should make this consistent with aiohttp. Thanks.

@alessio-locatelli alessio-locatelli changed the title test: extend 'test_streaming_requests' Fix CachedResposnse.read() and ClientResponse.read() consistency Oct 30, 2024
Copy link

codecov bot commented Oct 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.17%. Comparing base (fb00280) to head (ffbd394).
Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #279   +/-   ##
=======================================
  Coverage   96.17%   96.17%           
=======================================
  Files          10       10           
  Lines        1072     1072           
  Branches      188      188           
=======================================
  Hits         1031     1031           
  Misses         30       30           
  Partials       11       11           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@alessio-locatelli alessio-locatelli added the bug Something isn't working label Oct 30, 2024
@alessio-locatelli alessio-locatelli marked this pull request as ready for review October 30, 2024 15:51
@JWCook JWCook merged commit bd0bc75 into requests-cache:main Nov 7, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CachedResposnse.read() and ClientResponse.read() have inconsistent behavior
2 participants