Skip to content

Commit

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

Co-authored-by: J. Nick Koston <[email protected]>
  • Loading branch information
patchback[bot] and bdraco authored Nov 20, 2024
1 parent a4269dc commit e6eacd7
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 @@ -521,10 +521,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_headers = None
Expand Down Expand Up @@ -637,7 +642,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 e6eacd7

Please sign in to comment.