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
maxThe ceiling. Defaults to
BodySizeLimit.default, this request’smaxBodySize.
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.