Skip to content

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

Instance Method

data(max:)

The body’s bytes, collecting the stream first if nothing has collected it yet.
func data(max: BodySizeLimit = .default) async throws -> Data?

Parameters

max

The ceiling, as collect(max:).

Return Value

The body’s bytes, or nil if the request has no body.

Discussion

The collecting counterpart to data, and what most handlers want: it does not care whether the body arrived on a socket or was already materialised, and an already-collected body is returned without re-reading anything.

Throws

Abort with .contentTooLarge if the body exceeds max.