open-webui/backend/open_webui/utils
Classic298 0f8846b7fc
fix: convert SecurityHeadersMiddleware to pure ASGI (#26924)
SecurityHeadersMiddleware was the last middleware in the stack still
subclassing BaseHTTPMiddleware, after CommitSession, AuthToken,
WebsocketUpgradeGuard and Redirect were all moved to pure ASGI in
utils/asgi_middleware.py. BaseHTTPMiddleware re-buffers the response
body through an anyio task group, which has known issues with
streaming and Content-Length-bearing responses (e.g. the FileResponse
returned by /api/v1/audio/speech).

Reimplement it as a pure-ASGI middleware that stamps the configured
security headers onto the http.response.start message via
MutableHeaders and forwards all body chunks untouched, matching the
pattern already used by its four siblings. set_security_headers() and
all its helpers are unchanged.

Co-authored-by: classic298 <classic298@users.noreply.github.com>
2026-07-10 13:29:14 -05:00
..
access_control refac 2026-06-29 11:53:29 -05:00
images refac 2026-07-01 02:48:29 -05:00
mcp refac 2026-06-29 11:56:00 -05:00
telemetry refac(telemetry): drop deprecated semconv SpanAttributes subclass (#25784) 2026-06-29 02:05:34 -05:00
actions.py refac 2026-07-09 17:28:34 -05:00
anthropic.py refac 2026-06-17 00:36:34 +02:00
asgi_middleware.py refac 2026-06-17 02:52:35 +02:00
audit.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
auth.py refac 2026-06-29 03:58:00 -05:00
automations.py refac 2026-07-01 02:49:28 -05:00
calendar.py feat: add repeat/recurrence dropdown to calendar event modal (#25865) 2026-06-29 02:16:19 -05:00
channels.py refac 2026-03-17 17:58:01 -05:00
chat.py Enforce per-model access on arena fallback before bypass_filter dispatch (#26046) 2026-06-16 22:45:42 +02:00
code_interpreter.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
context_compaction.py refac 2026-07-09 17:33:30 -05:00
embeddings.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
files.py perf(images): offload validate_url() DNS resolution with asyncio.to_thread (#25825) 2026-06-29 02:31:24 -05:00
filter.py refac 2026-07-09 17:28:34 -05:00
groups.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
headers.py feat: forward client User-Agent to model backends via {{USER_AGENT}} placeholder (#26333) 2026-06-29 05:58:19 -05:00
logger.py chore: format 2026-06-01 13:56:55 -07:00
memory.py refac 2026-07-01 03:35:46 -05:00
middleware.py refac 2026-07-09 17:38:19 -05:00
misc.py refac 2026-06-29 13:03:14 -05:00
models.py refac 2026-07-09 17:28:34 -05:00
oauth.py refac 2026-07-01 02:57:29 -05:00
payload.py refac 2026-06-29 00:18:40 -05:00
pdf_generator.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
plugin.py refac 2026-07-09 17:28:34 -05:00
rate_limit.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
redis.py fix(redis): use await asyncio.sleep() instead of time.sleep() in async generator (#25823) 2026-06-29 02:25:46 -05:00
response.py refac 2026-06-23 23:35:44 +02:00
sanitize.py refac 2026-03-17 17:58:01 -05:00
security_headers.py fix: convert SecurityHeadersMiddleware to pure ASGI (#26924) 2026-07-10 13:29:14 -05:00
session_pool.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
task.py refac 2026-06-19 00:16:06 +02:00
tools.py refac 2026-07-09 17:37:04 -05:00
validate.py chore: format 2026-06-01 13:56:55 -07:00
valves.py refac 2026-06-29 12:29:10 -05:00
webhook.py refac 2026-06-29 13:03:14 -05:00