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 a streaming body first if nothing has collected it yet.
func data(max: BodySizeLimit = .default) async throws -> Data?

Parameters

max

The most bytes to buffer, as collect(max:). nil buffers 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.