diff options
author | Noémi Ványi <sitbackandwait@gmail.com> | 2020-12-09 17:33:18 +0100 |
---|---|---|
committer | Noémi Ványi <sitbackandwait@gmail.com> | 2020-12-09 20:49:54 +0100 |
commit | 3a63dfbdd7ff53c2e083915b0dea481a6ea0aaaa (patch) | |
tree | e87938d67386bb7d0272c14e1902867eeb152676 /searx/engines/__init__.py | |
parent | 42a194898baf96e15edeb9268fbec5ecd4423c09 (diff) | |
download | searxng-3a63dfbdd7ff53c2e083915b0dea481a6ea0aaaa.tar.gz searxng-3a63dfbdd7ff53c2e083915b0dea481a6ea0aaaa.zip |
display if an engine does not support https
Closes #302
Diffstat (limited to 'searx/engines/__init__.py')
-rw-r--r-- | searx/engines/__init__.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py index ddd6a7feb..0b77f2a95 100644 --- a/searx/engines/__init__.py +++ b/searx/engines/__init__.py @@ -20,6 +20,7 @@ import sys import threading from os.path import realpath, dirname from babel.localedata import locale_identifiers +from urllib.parse import urlparse from flask_babel import gettext from operator import itemgetter from searx import settings @@ -289,3 +290,34 @@ def initialize_engines(engine_list): if init_fn: logger.debug('%s engine: Starting background initialization', engine_name) threading.Thread(target=engine_init, args=(engine_name, init_fn)).start() + + _set_https_support_for_engine(engine) + + +def _set_https_support_for_engine(engine): + # check HTTPS support if it is not disabled + if not engine.offline and not hasattr(engine, 'https_support'): + params = engine.request('http_test', { + 'method': 'GET', + 'headers': {}, + 'data': {}, + 'url': '', + 'cookies': {}, + 'verify': True, + 'auth': None, + 'pageno': 1, + 'time_range': None, + 'language': '', + 'safesearch': False, + 'is_test': True, + 'category': 'files', + 'raise_for_status': True, + }) + + if 'url' not in params: + return + + parsed_url = urlparse(params['url']) + https_support = parsed_url.scheme == 'https' + + setattr(engine, 'https_support', https_support) |