Skip to content

[rejected AI] fix: respect per-request body size limits - #477

Closed
KayanoLiam wants to merge 1 commit into
pallets:mainfrom
KayanoLiam:request-body-limits
Closed

KayanoLiam wants to merge 1 commit into
pallets:mainfrom
KayanoLiam:request-body-limits

Conversation

@KayanoLiam

Copy link
Copy Markdown

Setting request.max_content_length before reading a request body now takes effect. Routes can disable the limit with None, increase it for an upload, or impose a smaller limit without changing the application-wide setting.

Check the declared Content-Length when the body is consumed instead of caching a 413 during construction. Keep the body's limit in sync with the request property, and distinguish an explicit None override from the default application setting. Streaming without Content-Length retains its existing behavior.

Fixes #425.

Validation on Python 3.13.7:

  • PYTHONPATH=src .venv/bin/python -m pytest -q: 303 passed, including 48 new cases covering buffered reads, streaming, forms, and requests with and without Content-Length.
  • PYTHONPATH=src .venv/bin/python -m mypy: passed.
  • Ruff lint and formatting checks on the changed files: passed.

@davidism

Copy link
Copy Markdown
Member

@davidism davidism changed the title fix: respect per-request body size limits [rejected AI] fix: respect per-request body size limits Sep 13, 2026
@davidism davidism closed this Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow max content length to be modified on a per-request basis

2 participants