Instance Method
data(max:)
The body’s bytes, collecting a streaming body first if nothing has collected it yet.
func data(max: BodySizeLimit = .default) async throws -> Data?
Parameters
maxThe most bytes to buffer, as
collect(max:).nilbuffers whatever the body produces.
Return Value
The body’s bytes, or nil if the body is empty.
Discussion
The collecting counterpart to data, for where the body may or may not be a stream and the bytes are genuinely needed - a client response, say. An already-collected or buffered body is returned without re-reading anything.
Throws
Abort with .contentTooLarge if a streaming body exceeds max.