Skip to content

Commit 496f649

Browse files
[PR #10004/a334eef7 backport][3.11] Avoid building skip_headers in ClientSession._request if it will be thrown away (#10006)
Co-authored-by: J. Nick Koston <[email protected]>
1 parent d030c05 commit 496f649

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

aiohttp/client.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -540,10 +540,15 @@ async def _request(
540540
if url.scheme not in self._connector.allowed_protocol_schema_set:
541541
raise NonHttpUrlClientError(url)
542542

543-
skip_headers = set(self._skip_auto_headers)
543+
skip_headers: Optional[Iterable[istr]]
544544
if skip_auto_headers is not None:
545-
for i in skip_auto_headers:
546-
skip_headers.add(istr(i))
545+
skip_headers = {
546+
istr(i) for i in skip_auto_headers
547+
} | self._skip_auto_headers
548+
elif self._skip_auto_headers:
549+
skip_headers = self._skip_auto_headers
550+
else:
551+
skip_headers = None
547552

548553
if proxy is None:
549554
proxy = self._default_proxy
@@ -670,7 +675,7 @@ async def _request(
670675
url,
671676
params=params,
672677
headers=headers,
673-
skip_auto_headers=skip_headers if skip_headers else None,
678+
skip_auto_headers=skip_headers,
674679
data=data,
675680
cookies=all_cookies,
676681
auth=auth,

0 commit comments

Comments
 (0)