Skip to content

Commit

Permalink
Simplify keep_alive logic in ClientRequest (#9817)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Nov 11, 2024
1 parent 49dd714 commit 5be7256
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions aiohttp/client_reqrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,16 +552,13 @@ def update_proxy(
self.proxy_headers = proxy_headers

def keep_alive(self) -> bool:
if self.version < HttpVersion10:
# keep alive not supported at all
return False
if self.version >= HttpVersion11:
return self.headers.get(hdrs.CONNECTION) != "close"
if self.version == HttpVersion10:
# no headers means we close for Http 1.0
return self.headers.get(hdrs.CONNECTION) == "keep-alive"
elif self.headers.get(hdrs.CONNECTION) == "close":
return False

return True
# keep alive not supported at all
return False

async def write_bytes(
self, writer: AbstractStreamWriter, conn: "Connection"
Expand Down

0 comments on commit 5be7256

Please sign in to comment.