[fix] webapp.py: default_http_headers not parsed as strings (#5094)

WhiteNoise requires all headers to be strings, however it's common to use
other primitive types (e.g. numbers) in the header, e.g. `X-XSS-Protection: 0`.
Thus, we must convert all types of values (i.e. numbers) to strings.

- closes https://github.com/searxng/searxng/issues/5091
This commit is contained in:
Bnyro 2025-08-07 20:50:31 +02:00 committed by GitHub
parent 4942c9b914
commit 612b76b75e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1387,7 +1387,8 @@ def static_headers(headers: Headers, _path: str, _url: str) -> None:
headers['Cache-Control'] = 'public, max-age=30, stale-while-revalidate=60'
for header, value in settings['server']['default_http_headers'].items():
headers[header] = value
# cast value to string, as WhiteNoise requires header values to be strings
headers[header] = str(value)
app.wsgi_app = WhiteNoise(