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

Avoid building skip_headers in ClientSession._request if it will be thrown away #10004

Merged
merged 8 commits into from
Nov 20, 2024
Merged
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
13 changes: 9 additions & 4 deletions aiohttp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,10 +490,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 @@ -613,7 +618,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
Loading