Skip to content

Commit 602552e

Browse files
[PR #9772/eaa10860 backport][3.11] Combine duplicate logic in Response.write_eof (#9774)
Co-authored-by: J. Nick Koston <[email protected]>
1 parent 14fd4ca commit 602552e

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

aiohttp/web_response.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -753,16 +753,13 @@ async def write_eof(self, data: bytes = b"") -> None:
753753
assert not data, f"data arg is not supported, got {data!r}"
754754
assert self._req is not None
755755
assert self._payload_writer is not None
756-
if body is not None:
757-
if self._must_be_empty_body:
758-
await super().write_eof()
759-
elif isinstance(self._body, Payload):
760-
await self._body.write(self._payload_writer)
761-
await super().write_eof()
762-
else:
763-
await super().write_eof(cast(bytes, body))
764-
else:
756+
if body is None or self._must_be_empty_body:
765757
await super().write_eof()
758+
elif isinstance(self._body, Payload):
759+
await self._body.write(self._payload_writer)
760+
await super().write_eof()
761+
else:
762+
await super().write_eof(cast(bytes, body))
766763

767764
async def _start(self, request: "BaseRequest") -> AbstractStreamWriter:
768765
if hdrs.CONTENT_LENGTH in self._headers:

0 commit comments

Comments
 (0)