Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DNM: Attempt to speed up version checks in client #9897

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions aiohttp/client_reqrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,20 +680,19 @@ async def send(self, conn: "Connection") -> "ClientResponse":

# set the connection header
connection = self.headers.get(hdrs.CONNECTION)
v_major, v_minor = self.version
if not connection:
if self.keep_alive():
if self.version == HttpVersion10:
if v_major == 1 and v_minor == 0:
connection = "keep-alive"
else:
if self.version == HttpVersion11:
connection = "close"
elif v_major == 1 and v_minor == 1:
connection = "close"

if connection is not None:
self.headers[hdrs.CONNECTION] = connection

# status + headers
v = self.version
status_line = f"{self.method} {path} HTTP/{v.major}.{v.minor}"
status_line = f"{self.method} {path} HTTP/{v_major}.{v_minor}"
await writer.write_headers(status_line, self.headers)
task: Optional["asyncio.Task[None]"]
if self.body or self._continue is not None or protocol.writing_paused:
Expand Down
Loading