.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
http_connection.py
Go to the documentation of this file.
1
# SPDX-License-Identifier: AGPL-3.0-or-later
2
"""
3
Method ``http_connection``
4
--------------------------
5
6
The ``http_connection`` method evaluates a request as the request of a bot if
7
the Connection_ header is set to ``close``.
8
9
.. _Connection:
10
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Connection
11
12
"""
13
# pylint: disable=unused-argument
14
15
from
__future__
import
annotations
16
from
ipaddress
import
(
17
IPv4Network,
18
IPv6Network,
19
)
20
21
import
flask
22
import
werkzeug
23
24
from
.
import
config
25
from
._helpers
import
too_many_requests
26
27
28
def
filter_request
(
29
network: IPv4Network | IPv6Network,
30
request: flask.Request,
31
cfg:
config.Config
,
32
) -> werkzeug.Response |
None
:
33
34
if
request.headers.get(
'Connection'
,
''
).strip() ==
'close'
:
35
return
too_many_requests(network,
"HTTP header 'Connection=close"
)
36
return
None
searx.botdetection.config.Config
Definition
config.py:54
searx.botdetection.http_connection.filter_request
werkzeug.Response|None filter_request(IPv4Network|IPv6Network network, flask.Request request, config.Config cfg)
Definition
http_connection.py:32
searxng
searx
botdetection
http_connection.py
Generated on Sat Nov 16 2024 00:10:57 for .oO SearXNG Developer Documentation Oo. by
1.12.0