summaryrefslogtreecommitdiff
path: root/searx/search/processors
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarit.de>2022-08-01 17:01:59 +0200
committerMarkus Heiser <markus.heiser@darmarit.de>2022-08-01 17:01:59 +0200
commit8df1f0c47e03fe7525c40a2856dba950bab8998b (patch)
tree844dc7ca4d31f0ff97c07d1817dbfba591420b30 /searx/search/processors
parenta2badb4fe47eaa6df26b7bc0ef601cb9179edc3a (diff)
[mod] add 'Accept-Language' HTTP header to online processores
Most engines that support languages (and regions) use the Accept-Language from the WEB browser to build a response that fits to the language (and region). - add new engine option: send_accept_language_header Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/search/processors')
-rw-r--r--searx/search/processors/online.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/searx/search/processors/online.py b/searx/search/processors/online.py
index 0cfe6e123..17e9b6a96 100644
--- a/searx/search/processors/online.py
+++ b/searx/search/processors/online.py
@@ -60,6 +60,17 @@ class OnlineProcessor(EngineProcessor):
# add an user agent
params['headers']['User-Agent'] = gen_useragent()
+ # add Accept-Language header
+ if self.engine.send_accept_language_header and search_query.locale:
+ ac_lang = search_query.locale.language
+ if search_query.locale.territory:
+ ac_lang = "%s-%s,%s;q=0.9,*;q=0.5" % (
+ search_query.locale.language,
+ search_query.locale.territory,
+ search_query.locale.language,
+ )
+ params['headers']['Accept-Language'] = ac_lang
+
return params
def _send_http_request(self, params):