Skip to content

Commit

Permalink
Avoid building skip_headers in ClientSession._request if it will …
Browse files Browse the repository at this point in the history
…be thrown away (#10004)

(cherry picked from commit a334eef)
  • Loading branch information
bdraco authored and patchback[bot] committed Nov 20, 2024
1 parent e4bd744 commit d4ef0a7
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 d4ef0a7

Please sign in to comment.