diff options
| author | Alexandre Flament <alex@al-f.net> | 2021-03-08 11:35:08 +0100 |
|---|---|---|
| committer | Alexandre Flament <alex@al-f.net> | 2021-03-08 11:35:08 +0100 |
| commit | 99e0651ceaffdc9f57ca4fc1be50fdec8864f4cb (patch) | |
| tree | 6aa25c99e8c0f70cf04257615968203ae6ef808e /searx/poolrequests.py | |
| parent | 0d8b369b5b300e8a575d6715fc75067d09db63a5 (diff) | |
[mod] by default allow only HTTPS, not HTTP
Related to https://github.com/searx/searx/pull/2373
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 |