Protocol
HTTPBodyWriter
protocol HTTPBodyWriter : ~Escapable
Overview
Implementations of this protocol are provided by the HTTP server layer and allow Vapor’s response body types to write their data straight to the underlying connection. Writes are backpressured: write suspends while the transport can’t accept more data, so a streaming body naturally throttles to the speed of the client.
Only write is exposed: concluding the response is the server’s responsibility, so a body-stream closure can never end the stream itself.
A writer is non-escapable, and is only valid for the duration of the body-stream closure it was handed to. This ensures a write can never happen after the response was concluded See https://github.com/vapor/vapor/issues/2976.
Topics
Instance Methods
func write(_:)Write a single chunk of bytesfunc write(contentsOf: some Sequence<some Sequence<UInt8>>) async throwsWrite a sequence of byte chunks, in order This will copy the bytes into contiguous storage first. Use theSpanAPIs to avoid copies