Type Alias
ClientRequest.Body
The body of a request the client is about to send.
Discussion
The same type ClientResponse carries, and the same one a Response is built from: it holds either bytes or a closure that produces them. A streaming body is written the same way in either direction:
request.body = .init(string: "hello")
request.body = .init(stream: { writer in
for chunk in chunks { try await writer.write(chunk) }
})
Streaming is backpressured end to end: each write returns once the transport has taken the bytes, so a fast producer suspends against a slow connection rather than buffering.