You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Net.HTTP server: a settable request body limit, and streaming a large body #488
The server refuses any request body over 10 MiB (?BODY_LIMIT in kex_intrinsic_nethttpserver.erl) before the application sees it, and a program can't change that. ServerOptions has maximumHandlers, backlog and gracefulShutdown, but no size.
Below the limit, the whole body is read into memory before the handler runs.
Why it matters
File uploads, in Metro's Metro.Storage for Slick's chat attachments:
a video or a design file over 10 MiB can't be uploaded at all, whatever the application allows;
an application that wants less, say 2 MiB for avatars, still lets 10 MiB in before it can refuse.
Proposal
A settable limit:ServerOptions.maximumBodyBytes : Integer = 10485760, today's value as the default.
Per route: a way for a route to read a larger body. Otherwise an application must raise the limit for every route to allow it on one. This could be a per-request override, or a stream.
Streaming: handing the handler the body as a stream of chunks (Request<Stream<Binary>>, or a receive on the request). An upload can then be written to its destination as it arrives, with a running checksum, instead of being held whole in memory.
Over the limit: answer 413 Payload Too Large once the body is past it, with a body the application can't see. Check whether that's what happens today.
Activity