Skip to content

Enforce request body size when Content-Length is absent #27

Description

@laceyp99

Summary

Request body protection only checks the Content-Length header. If the client omits Content-Length or sends chunked transfer encoding, oversized bodies can bypass the limit.

Why this matters

The README already calls this out as a limitation, but it leaves a gap in local safety for agent clients that stream bodies or omit length headers.

Relevant code

  • app/request_limits.py:40-69
  • app/main.py:116-133
  • README.md:216

Current behavior

reject_request_body_if_too_large() returns 413 only when declared_content_length() is present and above the threshold. When length is missing, it returns None.

Suggested fix

Enforce the size limit on the actual bytes read from the request stream, or add a fallback path that rejects oversized bodies even without Content-Length.

Tests

Add a regression test for a POST or PATCH request without Content-Length, and verify the limit is still enforced.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-pr-openedMy custom label that signifies an agent has opened a PR on this issue.bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions