Skip to content

Commit

Permalink
[PR #10004/a334eef7 backport][3.11] Avoid building skip_headers in …
Browse files Browse the repository at this point in the history
…`ClientSession._request` if it will be thrown away (#10006)

Co-authored-by: J. Nick Koston <[email protected]>
  • Loading branch information
patchback[bot] and bdraco authored Nov 20, 2024
1 parent d030c05 commit 496f649
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions aiohttp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,15 @@ async def _request(
if url.scheme not in self._connector.allowed_protocol_schema_set:
raise NonHttpUrlClientError(url)

skip_headers = set(self._skip_auto_headers)
skip_headers: Optional[Iterable[istr]]
if skip_auto_headers is not None:
for i in skip_auto_headers:
skip_headers.add(istr(i))
skip_headers = {
istr(i) for i in skip_auto_headers
} | self._skip_auto_headers
elif self._skip_auto_headers:
skip_headers = self._skip_auto_headers
else:
skip_headers = None

if proxy is None:
proxy = self._default_proxy
Expand Down Expand Up @@ -670,7 +675,7 @@ async def _request(
url,
params=params,
headers=headers,
skip_auto_headers=skip_headers if skip_headers else None,
skip_auto_headers=skip_headers,
data=data,
cookies=all_cookies,
auth=auth,
Expand Down

0 comments on commit 496f649

Please sign in to comment.