Protocol
RequestBodyReader
Reads an HTTP request body, pulled straight off the connection with backpressure (the server stops reading until the handler asks for more). Implementations come from the HTTP server layer.
protocol RequestBodyReader : ~Escapable
Overview
Non-escapable: valid only for the duration of the withReader(_:) closure it was lent to, so the body can’t be read after the request moved on and “read it twice” is a compile-time error.
Topics
Instance Methods
func forEachChunk((Span<UInt8>) async throws -> Void) async throwsReads the whole remaining body, callingbodyonce per chunk in order, until it ends.func read<R>((Span<UInt8>, Bool) async throws -> R) async throws -> RReads the next part of the body, handing its bytes tobodyas a borrowedSpan<UInt8>along with a flag that istrueonce the body has ended (in which case the span is empty).