Skip to content

Commit 0ca67bb

Browse files
[PR #9817/5be7256c backport][3.11] Simplify keep_alive logic in ClientRequest (#9821)
Co-authored-by: J. Nick Koston <[email protected]>
1 parent 0b647f6 commit 0ca67bb

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

aiohttp/client_reqrep.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -614,16 +614,13 @@ def update_proxy(
614614
self.proxy_headers = proxy_headers
615615

616616
def keep_alive(self) -> bool:
617-
if self.version < HttpVersion10:
618-
# keep alive not supported at all
619-
return False
617+
if self.version >= HttpVersion11:
618+
return self.headers.get(hdrs.CONNECTION) != "close"
620619
if self.version == HttpVersion10:
621620
# no headers means we close for Http 1.0
622621
return self.headers.get(hdrs.CONNECTION) == "keep-alive"
623-
elif self.headers.get(hdrs.CONNECTION) == "close":
624-
return False
625-
626-
return True
622+
# keep alive not supported at all
623+
return False
627624

628625
async def write_bytes(
629626
self, writer: AbstractStreamWriter, conn: "Connection"

0 commit comments

Comments
 (0)