diff options
author | Alexandre Flament <alex@al-f.net> | 2021-08-18 08:39:13 +0200 |
---|---|---|
committer | Alexandre Flament <alex@al-f.net> | 2021-09-17 10:06:24 +0200 |
commit | b10403d3a1c1da6a6c5bbb49bc891f26ff45f1f1 (patch) | |
tree | 4a29ca26cd61fbca622fada69d2b171840f042a7 /searx/network | |
parent | 8e73438cbed62ca5c16f6d3c6ce7220b17550c4b (diff) | |
download | searxng-b10403d3a1c1da6a6c5bbb49bc891f26ff45f1f1.tar.gz searxng-b10403d3a1c1da6a6c5bbb49bc891f26ff45f1f1.zip |
[mod] searx.network: remove redundant code
searx.client.new_client: the proxies parameter is a dictonnary,
and the protocol (key of the dictionnary) is already normalized
(see usage of searx.network.network.PROXY_PATTERN_MAPPING)
Diffstat (limited to 'searx/network')
-rw-r--r-- | searx/network/client.py | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/searx/network/client.py b/searx/network/client.py index 46edf9b6b..f388523b5 100644 --- a/searx/network/client.py +++ b/searx/network/client.py @@ -183,15 +183,6 @@ def get_transport(verify, http2, local_address, proxy_url, limit, retries): ) -def iter_proxies(proxies): - # https://www.python-httpx.org/compatibility/#proxy-keys - if isinstance(proxies, str): - yield 'all://', proxies - elif isinstance(proxies, dict): - for pattern, proxy_url in proxies.items(): - yield pattern, proxy_url - - def new_client( # pylint: disable=too-many-arguments enable_http, verify, enable_http2, @@ -204,11 +195,11 @@ def new_client( ) # See https://www.python-httpx.org/advanced/#routing mounts = {} - for pattern, proxy_url in iter_proxies(proxies): - if not enable_http and (pattern == 'http' or pattern.startswith('http://')): + for pattern, proxy_url in proxies.items(): + if not enable_http and pattern.startswith('http://'): continue if (proxy_url.startswith('socks4://') - or proxy_url.startswith('socks5://') + or proxy_url.startswith('socks5://') or proxy_url.startswith('socks5h://') ): mounts[pattern] = get_transport_for_socks_proxy( |