Structure
Response.Body
Represents a
Response’s body.struct Body
Overview
let body = Response.Body(string: "Hello, world!")
This can contain any data (streaming or static) and should match the message’s "Content-Type" header.
Topics
Initializers
init(asyncStream:byteBufferAllocator:)Creates a chunked HTTPResponsesteam usingAsyncBodyStreamWriter.init(asyncStream:count:byteBufferAllocator:)Creates a chunked HTTPResponsesteam usingAsyncBodyStreamWriter.init(buffer:byteBufferAllocator:)Create a new body from a Swift NIOByteBuffer.init(byteBufferAllocator:)Creates an empty body. Useful forGETrequests where HTTP bodies are forbidden.init(data:byteBufferAllocator:)Create a new body wrappingData.init(dispatchData:byteBufferAllocator:)Create a new body wrappingDispatchData.init(managedAsyncStream:byteBufferAllocator:)Creates a managed chunked HTTPResponsesteam usingAsyncBodyStreamWriterthat automtically closes or fails based if the closure throws an error or returns.init(managedAsyncStream:count:byteBufferAllocator:)Creates a managed chunked HTTPResponsesteam usingAsyncBodyStreamWriterthat automtically closes or fails based if the closure throws an error or returns.init(staticString:byteBufferAllocator:)Create a new body from the UTF8 representation of aStaticString.init(stream:byteBufferAllocator:)init(stream:count:byteBufferAllocator:)init(string:byteBufferAllocator:)Create a new body from the UTF8 representation of aString.init(stringLiteral:)ExpressibleByStringLiteralconformance.
Instance Properties
buffercountThe size of the HTTP body’s data.-1is a chunked stream.dataReturns static data if not streaming.descriptionSeeCustomDebugStringConvertible.string
Instance Methods
Type Properties
emptyAn emptyResponse.Body.
Relationships
Conforms To
Swift.CustomStringConvertibleSwift.ExpressibleByExtendedGraphemeClusterLiteralSwift.ExpressibleByStringLiteralSwift.ExpressibleByUnicodeScalarLiteralSwift.SendableSwift.SendableMetatype