Skip to content

You're viewing documentation for a pre-release version. View the latest stable version

Protocol

HTTPBodyWriter

Protocol for writing HTTP response bodies.
protocol HTTPBodyWriter : ~Escapable

Overview

Implementations of this protocol are provided by the HTTP server layer and allow Vapor’s response body types to write their data straight to the underlying connection. Writes are backpressured: write suspends while the transport can’t accept more data, so a streaming body naturally throttles to the speed of the client.

Only write is exposed: concluding the response is the server’s responsibility, so a body-stream closure can never end the stream itself.

A writer is non-escapable, and is only valid for the duration of the body-stream closure it was handed to. This ensures a write can never happen after the response was concluded See https://github.com/vapor/vapor/issues/2976.

Topics

Instance Methods