fix/upload-size-check #7

Merged
patillacode merged 2 commits from fix/upload-size-check into main 2026-05-31 20:09:10 +02:00
Owner
  • Add early Content-Length header check in the upload handler: rejects obviously oversized requests before reading a
    single byte of the body
  • Replace await file.read() with an 8 KB chunked read loop that aborts as soon as the accumulated buffer exceeds
    max_upload_size, preventing the full body from ever being buffered in memory
  • Both layers use the existing max_upload_size setting and return the same HTTP 413 response

Previously a client could force the server to allocate up to 5 MB of memory per request regardless of the configured
cap, since the size check only fired after the full body was already in memory.

- Add early `Content-Length` header check in the upload handler: rejects obviously oversized requests before reading a single byte of the body - Replace `await file.read()` with an 8 KB chunked read loop that aborts as soon as the accumulated buffer exceeds `max_upload_size`, preventing the full body from ever being buffered in memory - Both layers use the existing `max_upload_size` setting and return the same HTTP 413 response Previously a client could force the server to allocate up to 5 MB of memory per request regardless of the configured cap, since the size check only fired after the full body was already in memory.
patillacode deleted branch fix/upload-size-check 2026-05-31 20:09:10 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
patillacode/dropit!7
No description provided.