summaryrefslogtreecommitdiff
path: root/searx/network/network.py
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2025-05-24 12:40:05 +0200
committerGitHub <noreply@github.com>2025-05-24 12:40:05 +0200
commit9ed9a9aa53a17df476437fb16c24c44e7c345f56 (patch)
treef0626ffcffd148b03ef50e404b20e2e33c162656 /searx/network/network.py
parent230215c250ac7937f7c0d6690f6ed64cd03350a9 (diff)
[fix] searx.network: don't trigger DeprecationWarning (#4845)
Avoid a confusing warning: DeprecationWarning: Setting per-request cookies=<...> is being deprecated Code based on httpx unit test [1] [1] https://github.com/encode/httpx/blob/6a99f6f2b3a638719f70200de9983f80d618ee1c/tests/client/test_cookies.py#L123-L137 Closes: https://github.com/searxng/searxng/issues/4833
Diffstat (limited to 'searx/network/network.py')
-rw-r--r--searx/network/network.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/searx/network/network.py b/searx/network/network.py
index 178ebcbf2..8e2a1f12d 100644
--- a/searx/network/network.py
+++ b/searx/network/network.py
@@ -180,7 +180,7 @@ class Network:
Network._TOR_CHECK_RESULT[proxies] = result
return result
- async def get_client(self, verify=None, max_redirects=None):
+ async def get_client(self, verify=None, max_redirects=None) -> httpx.AsyncClient:
verify = self.verify if verify is None else verify
max_redirects = self.max_redirects if max_redirects is None else max_redirects
local_address = next(self._local_addresses_cycle)
@@ -269,6 +269,8 @@ class Network:
kwargs_clients = Network.extract_kwargs_clients(kwargs)
while retries >= 0: # pragma: no cover
client = await self.get_client(**kwargs_clients)
+ cookies = kwargs.pop("cookies", None)
+ client.cookies = httpx.Cookies(cookies)
try:
if stream:
response = client.stream(method, url, **kwargs)