Skip to content

Initializer

init(status:version:headers:body:)

Creates a new Response.
convenience init(status: HTTPResponseStatus = .ok, version: HTTPVersion = .init(major: 1, minor: 1), headers: HTTPHeaders = .init(), body: Response.Body = .empty)

Parameters

status

HTTPResponseStatus to use. This defaults to HTTPResponseStatus.ok

version

HTTPVersion of this response, should usually be (and defaults to) 1.1.

headers

HTTPHeaders to include with this response. Defaults to empty headers. The "Content-Length" and "Transfer-Encoding" headers will be set automatically.

body

Body for this response, defaults to an empty body. See Response.Body for more information.

Discussion

let res = Response(status: .ok)