Skip to content

Commit

Permalink
Fix missing eof when writer cancelled (aio-libs#7764) (aio-libs#7781)
Browse files Browse the repository at this point in the history
Fixes aio-libs#5220.

I believe this is a better fix than aio-libs#5238. That PR detects that we
didn't finish sending a chunked response and then closes the connection.
This PR ensures that we simply complete the chunked response by sending
the EOF bytes, allowing the connection to remain open and be reused
normally.

(cherry picked from commit 9c07121)
  • Loading branch information
Dreamsorcerer authored and Xiang Li committed Dec 4, 2023
1 parent 70b2fa7 commit 1f9f1a9
Show file tree
Hide file tree
Showing 5 changed files with 265 additions and 159 deletions.
1 change: 1 addition & 0 deletions CHANGES/7764.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed an issue when a client request is closed before completing a chunked payload -- by :user:`Dreamsorcerer`
1 change: 1 addition & 0 deletions aiohttp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,7 @@ async def __aexit__(
# explicitly. Otherwise connection error handling should kick in
# and close/recycle the connection as required.
self._resp.release()
await self._resp.wait_for_close()


class _WSRequestContextManager(_BaseRequestContextManager[ClientWebSocketResponse]):
Expand Down
Loading

0 comments on commit 1f9f1a9

Please sign in to comment.