INNER CODE UNIT · Python
_MAX_YAML_REQUEST_BYTES
MakazhanAlpamys/Soup · src/soup_cli/ui/app.py:32
_MAX_YAML_REQUEST_BYTES = 1024 * 1024
_BODY_SIZE_LIMITS = {
"/api/chat/send": _MAX_CHAT_SEND_BODY_BYTES,
"/api/data/inspect": _MAX_DATA_INSPECT_BODY_BYTES,
"/api/config/validate": _MAX_YAML_REQUEST_BYTES,
"/api/train/start": _MAX_YAML_REQUEST_BYTES,
"/api/config/from-form": _MAX_YAML_REQUEST_BYTES,
}
class _RequestBodySizeLimitMiddleware:
"""Reject an oversized POST body before route/model parsing runs.
Checks ``Content-Length`` first, then streams and counts the actual body
bytes so a missing or understated header cannot bypass the cap. Per-route
limits keep the mechanism shared while allowing small JSON requests and
YAML-bearing configuration requests to use different ceilings.
"""