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

Release HTTP response before raising status exception #3365

Merged
merged 1 commit into from
Nov 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/3364.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Release HTTP response before raising status exception
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ Gregory Haynes
Gus Goulart
Gustavo Carneiro
Günther Jena
Hans Adema
Harmon Y.
Hu Bo
Hugo Herter
Expand Down
1 change: 1 addition & 0 deletions aiohttp/client_reqrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,7 @@ def release(self) -> Any:
def raise_for_status(self) -> None:
if 400 <= self.status:
assert self.reason # always not None for started response
self.release()
raise ClientResponseError(
self.request_info,
self.history,
Expand Down
1 change: 1 addition & 0 deletions tests/test_client_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ def test_raise_for_status_4xx() -> None:
response.raise_for_status()
assert str(cm.value.status) == '409'
assert str(cm.value.message) == "CONFLICT"
assert response.closed


def test_resp_host() -> None:
Expand Down