diff options
| author | Alexandre Flament <alex@al-f.net> | 2021-03-12 19:21:46 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-12 19:21:46 +0100 |
| commit | a1a492baed8f6d531ea95cf4fde539e48328f3cb (patch) | |
| tree | cfb20a8974598c0fd90d2426220e95366cef480c /searx/poolrequests.py | |
| parent | af3e969c5a4d7b9170076ffc74ec52b24f00915c (diff) | |
| parent | 99e0651ceaffdc9f57ca4fc1be50fdec8864f4cb (diff) | |
Merge pull request #2641 from dalf/disable_http_by_default
[mod] by default allow only HTTPS, not HTTP
Diffstat (limited to 'searx/poolrequests.py')
| -rw-r--r-- | searx/poolrequests.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/searx/poolrequests.py b/searx/poolrequests.py index 8b8681437..ab327251b 100644 --- a/searx/poolrequests.py +++ b/searx/poolrequests.py @@ -91,9 +91,10 @@ class SessionSinglePool(requests.Session): self.adapters.clear() https_adapter = threadLocal.__dict__.setdefault('https_adapter', next(https_adapters)) - http_adapter = threadLocal.__dict__.setdefault('http_adapter', next(http_adapters)) self.mount('https://', https_adapter) - self.mount('http://', http_adapter) + if get_enable_http_protocol(): + http_adapter = threadLocal.__dict__.setdefault('http_adapter', next(http_adapters)) + self.mount('http://', http_adapter) def close(self): """Call super, but clear adapters since there are managed globaly""" @@ -106,6 +107,17 @@ def set_timeout_for_thread(timeout, start_time=None): threadLocal.start_time = start_time +def set_enable_http_protocol(enable_http): + threadLocal.enable_http = enable_http + + +def get_enable_http_protocol(): + try: + return threadLocal.enable_http + except AttributeError: + return False + + def reset_time_for_thread(): threadLocal.total_time = 0 |