-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Eliminate side-effects from the ClientResponse.ok
property
#5404
Conversation
@adamko147 your local Git is misconfigured: the commit author email doesn't match any emails verified on GitHub. You may want to fix that. |
Codecov Report
@@ Coverage Diff @@
## master #5404 +/- ##
==========================================
+ Coverage 96.74% 97.15% +0.40%
==========================================
Files 41 41
Lines 8736 8742 +6
Branches 1402 1402
==========================================
+ Hits 8452 8493 +41
+ Misses 149 130 -19
+ Partials 135 119 -16
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
@webknjaz thanks! Do I need to open new PR with correct email? |
I think we should be able to make a simple regression test in test_client_response.py to ensure this doesn't happen again. |
@adamko147 you can set up the correct name and email locally with |
@webknjaz thanks, wasn't sure whether I'm able to do force-push. should be ok now |
The branch is in your own fork, you can do anything you please there with no restrictions unless you set up your fork to forbid things. |
Co-authored-by: Sviatoslav Sydorenko <[email protected]>
Hi @Dreamsorcerer, I'm looking into the tests... most of the tests there mock the |
Sounds good to me. Probably just a |
tests/test_client_response.py
Outdated
@@ -1243,3 +1243,22 @@ def test_response_links_empty(loop: Any, session: Any) -> None: | |||
) | |||
response._headers = CIMultiDict() | |||
assert response.links == {} | |||
|
|||
|
|||
def test_response_not_closed_after_get_ok() -> None: |
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 could use mocker.spy()
on response.raise_for_status
method to verify that it wasn't called in addition to checking the side-effects.
ClientResponse.ok
property
Hm... Automatic backport failed for some obscure reason: https://github.com/aio-libs/aiohttp/runs/1701449441?check_suite_focus=true#step:3:31. @adamko147 mind creating a backport PR to |
…5407) This change makes it so accessing `ClientResponse.ok` only does the status code check. Prior to this commit, it'd call `ClientResponse.raise_for_status()` which in turn, closed the underlying TCP session whenever the status was 400 or higher making it effectively impossible to keep working with the response, including reading the HTTP response payload. PR #5404 by @adamko147 Fixes #5403 Co-authored-by: Sviatoslav Sydorenko <[email protected]> (cherry picked from commit 3250c5d) Co-authored-by: Adam Horacek <[email protected]>
This change makes it so accessing `ClientResponse.ok` only does the status code check. Prior to this commit, it'd call `ClientResponse.raise_for_status()` which in turn, closed the underlying TCP session whenever the status was 400 or higher making it effectively impossible to keep working with the response, including reading the HTTP response payload. PR aio-libs#5404 by @adamko147 Fixes aio-libs#5403 Co-authored-by: Sviatoslav Sydorenko <[email protected]>
This change makes it so accessing `ClientResponse.ok` only does the status code check. Prior to this commit, it'd call `ClientResponse.raise_for_status()` which in turn, closed the underlying TCP session whenever the status was 400 or higher making it effectively impossible to keep working with the response, including reading the HTTP response payload. PR aio-libs#5404 by @adamko147 Fixes aio-libs#5403 Co-authored-by: Sviatoslav Sydorenko <[email protected]>
This change makes it so accessing `ClientResponse.ok` only does the status code check. Prior to this commit, it'd call `ClientResponse.raise_for_status()` which in turn, closed the underlying TCP session whenever the status was 400 or higher making it effectively impossible to keep working with the response, including reading the HTTP response payload. PR aio-libs#5404 by @adamko147 Fixes aio-libs#5403 Co-authored-by: Sviatoslav Sydorenko <[email protected]>
Make
ClientResponse.ok
property only check theself.status
for 400+ status codes and reuse it inraise_for_status
methodAre there changes in behavior for the user?
Yes. User will be allowed to use code
Related issue number
fixes #5403
Checklist
CONTRIBUTORS.txt
CHANGES
folder<issue_id>.<type>
for example (588.bugfix)issue_id
change it to the pr id after creating the pr.feature
: Signifying a new feature..bugfix
: Signifying a bug fix..doc
: Signifying a documentation improvement..removal
: Signifying a deprecation or removal of public API..misc
: A ticket has been closed, but it is not of interest to users.