Skip to content

You're viewing documentation for a pre-release version. View the latest stable version

Instance Method

collect(max:)

Buffers the body into memory, aborting with 413 if it exceeds the ceiling.
func collect(max: BodySizeLimit = .default) async throws -> Data?

Parameters

max

The ceiling. Defaults to BodySizeLimit.default, this request’s maxBodySize.

Discussion

For an unread stream, aborts with 413 if the declared Content-Length already exceeds the ceiling before reading anything; an under-declaring client is still caught while collecting. An already-buffered (or absent) body is returned as is — it was accepted under its original limit, so a smaller max on a later call doesn’t re-reject it.