.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
http_accept.py
Go to the documentation of this file.
1# SPDX-License-Identifier: AGPL-3.0-or-later
2"""
3Method ``http_accept``
4----------------------
5
6The ``http_accept`` method evaluates a request as the request of a bot if the
7Accept_ header ..
8
9- did not contain ``text/html``
10
11.. _Accept:
12 https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept
13
14"""
15
16from __future__ import annotations
17from ipaddress import (
18 IPv4Network,
19 IPv6Network,
20)
21
22import werkzeug
23
24from searx.extended_types import SXNG_Request
25
26from . import config
27from ._helpers import too_many_requests
28
29
31 network: IPv4Network | IPv6Network,
32 request: SXNG_Request,
33 cfg: config.Config, # pylint: disable=unused-argument
34) -> werkzeug.Response | None:
35
36 if 'text/html' not in request.accept_mimetypes:
37 return too_many_requests(network, "HTTP header Accept did not contain text/html")
38 return None
werkzeug.Response|None filter_request(IPv4Network|IPv6Network network, SXNG_Request request, config.Config cfg)