diff --git a/aiohttp/client.py b/aiohttp/client.py index 31c76ff98af..56fd3925fa1 100644 --- a/aiohttp/client.py +++ b/aiohttp/client.py @@ -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 @@ -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,