mirror of
https://github.com/searxng/searxng.git
synced 2025-08-03 02:22:22 +02:00
[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>
This commit is contained in:
parent
a2badb4fe4
commit
8df1f0c47e
21 changed files with 52 additions and 26 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue