Class
Response
An HTTP response from a server back to the client.
final class Response
Overview
let res = Response(status: .ok)
See HTTPClient and HTTPServer.
Topics
Structures
struct BodyRepresents aResponse’s body.
Initializers
convenience init(status: HTTPResponseStatus, version: HTTPVersion, headers: HTTPHeaders, body: Response.Body)Creates a newResponse.init(status: HTTPResponseStatus, version: HTTPVersion, headersNoUpdate: HTTPHeaders, body: Response.Body)Internal init that creates a newResponsewithout sanitizing headers.
Instance Properties
var body: Response.BodyTheBody. Updating this property will also update the associated transport headers.var content: any ContentContainervar cookies: HTTPCookiesGet and setHTTPCookiesfor thisResponse. This accesses the"Set-Cookie"header.var description: StringSeeCustomStringConvertiblevar headers: HTTPHeadersThe header fields for this HTTP response. The"Content-Length"and"Transfer-Encoding"headers will be set automatically when thebodyproperty is mutated.var status: HTTPResponseStatusThe HTTP response status.var storage: Storagevar upgrader: (any Upgrader)?Optional Upgrade behavior to apply to this response. currently, websocket upgrades are the only defined case.var version: HTTPVersionThe HTTP version that corresponds to this response.
Default Implementations
Relationships
Conforms To
AsyncResponseEncodableResponseEncodableSwift.CopyableSwift.CustomStringConvertibleSwift.EscapableSwift.SendableSwift.SendableMetatype