.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.botdetection.http_accept_encoding Namespace Reference

Functions

werkzeug.Response|None filter_request (IPv4Network|IPv6Network network, flask.Request request, config.Config cfg)
 

Detailed Description

Method ``http_accept_encoding``
-------------------------------

The ``http_accept_encoding`` method evaluates a request as the request of a
bot if the Accept-Encoding_ header ..

- did not contain ``gzip`` AND ``deflate`` (if both values are missed)
- did not contain ``text/html``

.. _Accept-Encoding:
   https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding

Function Documentation

◆ filter_request()

werkzeug.Response | None searx.botdetection.http_accept_encoding.filter_request ( IPv4Network | IPv6Network network,
flask.Request request,
config.Config cfg )

Definition at line 31 of file http_accept_encoding.py.

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