diff options
Diffstat (limited to 'searx/botdetection/http_accept.py')
| -rw-r--r-- | searx/botdetection/http_accept.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/searx/botdetection/http_accept.py b/searx/botdetection/http_accept.py index 60e2330ae..b78a86278 100644 --- a/searx/botdetection/http_accept.py +++ b/searx/botdetection/http_accept.py @@ -15,7 +15,12 @@ Accept_ header .. """ # pylint: disable=unused-argument -from typing import Optional +from __future__ import annotations +from ipaddress import ( + IPv4Network, + IPv6Network, +) + import flask import werkzeug @@ -23,7 +28,12 @@ from searx.tools import config from ._helpers import too_many_requests -def filter_request(request: flask.Request, cfg: config.Config) -> Optional[werkzeug.Response]: +def filter_request( + network: IPv4Network | IPv6Network, + request: flask.Request, + cfg: config.Config, +) -> werkzeug.Response | None: + if 'text/html' not in request.accept_mimetypes: - return too_many_requests(request, "HTTP header Accept did not contain text/html") + return too_many_requests(network, "HTTP header Accept did not contain text/html") return None |