.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
http_accept_encoding.py
Go to the documentation of this file.
1
# SPDX-License-Identifier: AGPL-3.0-or-later
2
"""
3
Method ``http_accept_encoding``
4
-------------------------------
5
6
The ``http_accept_encoding`` method evaluates a request as the request of a
7
bot if the Accept-Encoding_ header ..
8
9
- did not contain ``gzip`` AND ``deflate`` (if both values are missed)
10
- did not contain ``text/html``
11
12
.. _Accept-Encoding:
13
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding
14
15
"""
16
17
from
__future__
import
annotations
18
from
ipaddress
import
(
19
IPv4Network,
20
IPv6Network,
21
)
22
23
import
werkzeug
24
25
from
searx.extended_types
import
SXNG_Request
26
27
from
.
import
config
28
from
._helpers
import
too_many_requests
29
30
31
def
filter_request
(
32
network: IPv4Network | IPv6Network,
33
request: SXNG_Request,
34
cfg:
config.Config
,
# pylint: disable=unused-argument
35
) -> werkzeug.Response |
None
:
36
37
accept_list = [l.strip()
for
l
in
request.headers.get(
'Accept-Encoding'
,
''
).split(
','
)]
38
if
not
(
'gzip'
in
accept_list
or
'deflate'
in
accept_list):
39
return
too_many_requests(network,
"HTTP header Accept-Encoding did not contain gzip nor deflate"
)
40
return
None
searx.botdetection.config.Config
Definition
config.py:54
searx.botdetection.http_accept_encoding.filter_request
werkzeug.Response|None filter_request(IPv4Network|IPv6Network network, SXNG_Request request, config.Config cfg)
Definition
http_accept_encoding.py:35
searx.extended_types
Definition
extended_types.py:1
searxng
searx
botdetection
http_accept_encoding.py
Generated on Thu Feb 20 2025 20:12:42 for .oO SearXNG Developer Documentation Oo. by
1.13.2