.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
14
from
__future__
import
annotations
15
from
ipaddress
import
(
16
IPv4Network,
17
IPv6Network,
18
)
19
20
import
werkzeug
21
import
flask
22
23
from
.
import
config
24
from
._helpers
import
too_many_requests
25
26
27
def
filter_request
(
28
network: IPv4Network | IPv6Network,
29
request: flask.Request,
30
cfg:
config.Config
,
# pylint: disable=unused-argument
31
) -> werkzeug.Response |
None
:
32
33
if
request.headers.get(
'Connection'
,
''
).strip() ==
'close'
:
34
return
too_many_requests(network,
"HTTP header 'Connection=close"
)
35
return
None
searx.botdetection.config.Config
Definition
config.py:67
searx.botdetection.http_connection.filter_request
werkzeug.Response|None filter_request(IPv4Network|IPv6Network network, flask.Request request, config.Config cfg)
Definition
http_connection.py:31
searxng
searx
botdetection
http_connection.py
Generated on
for .oO SearXNG Developer Documentation Oo. by
1.14.0