Utility functions to resolve SSE buffer size and body-too-large status from env.
# Source: https://github.com/headroomlabs-ai/headroom | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
"""Validation policy for proxy request and stream limits."""
from __future__ import annotations
SSE_EVENT_MAX_BYTES_ENV = "HEADROOM_SSE_BUFFER_MAX_BYTES"
SSE_EVENT_MAX_BYTES_DEFAULT = 1 * 1024 * 1024
BODY_TOO_LARGE_STATUS_ENV = "HEADROOM_PROXY_BODY_TOO_LARGE_STATUS"
BODY_TOO_LARGE_STATUS_DEFAULT = 413
def resolve_sse_event_max_bytes(raw: str | None) -> int:
"""Resolve the per-event SSE size cap from an optional env string."""
if raw is None or raw == "":
return SSE_EVENT_MAX_BYTES_DEFAULT
try:
value = int(raw)
except ValueError as exc:
r
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key