|
@@ -20,6 +20,7 @@ import sys
|
|
import threading
|
|
import threading
|
|
from os.path import realpath, dirname
|
|
from os.path import realpath, dirname
|
|
from babel.localedata import locale_identifiers
|
|
from babel.localedata import locale_identifiers
|
|
|
|
+from urllib.parse import urlparse
|
|
from flask_babel import gettext
|
|
from flask_babel import gettext
|
|
from operator import itemgetter
|
|
from operator import itemgetter
|
|
from searx import settings
|
|
from searx import settings
|
|
@@ -289,3 +290,34 @@ def initialize_engines(engine_list):
|
|
if init_fn:
|
|
if init_fn:
|
|
logger.debug('%s engine: Starting background initialization', engine_name)
|
|
logger.debug('%s engine: Starting background initialization', engine_name)
|
|
threading.Thread(target=engine_init, args=(engine_name, init_fn)).start()
|
|
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)
|