init(dispatchData:byteBufferAllocator:)
Create a new body wrapping DispatchData
.
init(dispatchData: DispatchData, byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator())
Create a new body wrapping DispatchData
.
init(dispatchData: DispatchData, byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator())
s5Vapor8ResponseC4BodyV12dispatchData19byteBufferAllocatorAE8Dispatch0iE0V_7NIOCore04BytegH0Vtcfc
What are these?7Z25M
import Vapor
Vapor is a framework for building server applications, APIs and websites in Swift. It provides a safe, performant and scalable foundation for building large complex backends.
struct Body
Represents a Response
’s body.
final class Response
An HTTP response from a server back to the client.
struct DispatchData
struct ByteBufferAllocator
The preferred allocator for ByteBuffer
values. The allocation strategy is opaque but is currently libc’s malloc
, realloc
and free
.
init(asyncStream: @escaping (AsyncBodyStreamWriter) async throws -> (), byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator())
Creates a chunked HTTP Response
steam using AsyncBodyStreamWriter
.
init(asyncStream: @escaping (AsyncBodyStreamWriter) async throws -> (), count: Int, byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator())
Creates a chunked HTTP Response
steam using AsyncBodyStreamWriter
.
init(buffer: ByteBuffer, byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator())
Create a new body from a Swift NIO ByteBuffer
.
init(byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator())
Creates an empty body. Useful for GET
requests where HTTP bodies are forbidden.
init(data: Data, byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator())
Create a new body wrapping Data
.
init(managedAsyncStream: @escaping (AsyncBodyStreamWriter) async throws -> (), byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator())
Creates a managed chunked HTTP Response
steam using AsyncBodyStreamWriter
that automtically closes or fails based if the closure throws an error or returns.
init(managedAsyncStream: @escaping (AsyncBodyStreamWriter) async throws -> (), count: Int, byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator())
Creates a managed chunked HTTP Response
steam using AsyncBodyStreamWriter
that automtically closes or fails based if the closure throws an error or returns.
init(staticString: StaticString, byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator())
Create a new body from the UTF8 representation of a StaticString
.
@preconcurrency init(stream: @escaping (BodyStreamWriter) -> (), byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator())
@preconcurrency init(stream: @escaping (BodyStreamWriter) -> (), count: Int, byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator())
init(string: String, byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator())
Create a new body from the UTF8 representation of a String
.
init(stringLiteral value: String)
ExpressibleByStringLiteral
conformance.
static let empty: Body
An empty Response.Body
.
var buffer: ByteBuffer? { get }
var count: Int { get }
The size of the HTTP body’s data. -1
is a chunked stream.
var data: Data? { get }
Returns static data if not streaming.
var description: String { get }
See CustomDebugStringConvertible
.
var string: String? { get }
func collect(on eventLoop: EventLoop) -> EventLoopFuture<ByteBuffer?>