8000 Net.HTTP server: a settable request body limit, and streaming a large body · Issue #488 · kexhq/kex · GitHub
[go: up one dir, main page]

Skip to content

Net.HTTP server: a settable request body limit, and streaming a large body #488

Open

Description

@akoskovacs

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.

Related: #484 (the clients' limits).

Activity

  1. added this to the 0.4.0 milestone on Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0