Skip to content

Commit 3426707

Browse files
[PR #9772/eaa10860 backport][3.10] Combine duplicate logic in Response.write_eof (#9773)
Co-authored-by: J. Nick Koston <[email protected]>
1 parent 9d9d76b commit 3426707

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
@@ -736,16 +736,13 @@ async def write_eof(self, data: bytes = b"") -> None:
736736
assert not data, f"data arg is not supported, got {data!r}"
737737
assert self._req is not None
738738
assert self._payload_writer is not None
739-
if body is not None:
740-
if self._must_be_empty_body:
741-
await super().write_eof()
742-
elif isinstance(self._body, Payload):
743-
await self._body.write(self._payload_writer)
744-
await super().write_eof()
745-
else:
746-
await super().write_eof(cast(bytes, body))
747-
else:
739+
if body is None or self._must_be_empty_body:
748740
await super().write_eof()
741+
elif isinstance(self._body, Payload):
742+
await self._body.write(self._payload_writer)
743+
await super().write_eof()
744+
else:
745+
await super().write_eof(cast(bytes, body))
749746

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

0 commit comments

Comments
 (0)