Eliminate side-effects from the ClientResponse.ok property#5404
Eliminate side-effects from the ClientResponse.ok property#5404webknjaz merged 4 commits intoaio-libs:masterfrom adamko147:fix-5403
ClientResponse.ok property#5404Conversation
|
@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
| assert response.links == {} | ||
|
|
||
|
|
||
| def test_response_not_closed_after_get_ok() -> None: |
There was a problem hiding this comment.
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.okproperty only check theself.statusfor 400+ status codes and reuse it inraise_for_statusmethodAre there changes in behavior for the user?
Yes. User will be allowed to use code
Related issue number
fixes #5403
Checklist
CONTRIBUTORS.txtCHANGESfolder<issue_id>.<type>for example (588.bugfix)issue_idchange 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.