mirror of
https://github.com/searxng/searxng.git
synced 2025-06-28 19:49:53 +00:00
[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] 6a99f6f2b3/tests/client/test_cookies.py (L123-L137)
Closes: https://github.com/searxng/searxng/issues/4833
This commit is contained in:
parent
230215c250
commit
9ed9a9aa53
1 changed files with 3 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue