.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
http_accept_language.py
Go to the documentation of this file.
1# SPDX-License-Identifier: AGPL-3.0-or-later
2"""
3Method ``http_accept_language``
4-------------------------------
5
6The ``http_accept_language`` method evaluates a request as the request of a bot
7if the Accept-Language_ header is unset.
8
9.. _Accept-Language:
10 https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent
11
12"""
13# pylint: disable=unused-argument
14from __future__ import annotations
15from ipaddress import (
16 IPv4Network,
17 IPv6Network,
18)
19
20import flask
21import werkzeug
22
23from . import config
24from ._helpers import too_many_requests
25
26
28 network: IPv4Network | IPv6Network,
29 request: flask.Request,
30 cfg: config.Config,
31) -> werkzeug.Response | None:
32 if request.headers.get('Accept-Language', '').strip() == '':
33 return too_many_requests(network, "missing HTTP header Accept-Language")
34 return None
werkzeug.Response|None filter_request(IPv4Network|IPv6Network network, flask.Request request, config.Config cfg)