Skip to content

ResponseWriter

Josh Wright edited this page Jan 14, 2021 · 3 revisions

ResponseWriter

An abstraction around writing data to a remote peer. Conform to this protocol and inject it into the Response for responding to a remote peer at a later point in time.

public protocol ResponseWriter

Be sure to call writeEnd when you are finished writing data or the client response will never complete.

Requirements

writeHead(status:​_:​)

Write the status and head of a response. Should only be called once.

func writeHead(status: HTTPResponseStatus, _ headers: HTTPHeaders)

Parameters

  • status: The status code of the response.
  • headers: Any headers of this response.

writeBody(_:​)

Write some body data to the remote peer. May be called 0 or more times.

func writeBody(_ body: ByteBuffer)

Parameters

  • body: The buffer of data to write.

writeEnd()

Write the end of the response. Needs to be called once per response, when all data has been written.

func writeEnd()
Alchemy
Types
Protocols
Global Typealiases
Global Variables
Global Functions
Fusion
Types
Protocols
Papyrus
Types
Protocols
Clone this wiki locally