StreamResponseDefinition

open class StreamResponseDefinition<P, T>(val chunkFlow: <Error class: unknown class><T>? = null, val chunks: List<T>? = null, val delayBetweenChunks: <Error class: unknown class> = Duration.ZERO, contentType: <Error class: unknown class> = ContentType.Text.EventStream.withCharset(Charsets.UTF_8), httpStatus: <Error class: unknown class> = HttpStatusCode.OK, headers: <Error class: unknown class>.() -> Unit? = null, headerList: List<<Error class: unknown class><String, String>> = emptyList<Pair<String, String>>(), delay: <Error class: unknown class>) : AbstractResponseDefinition<T>

Represents a definition for streaming responses, supporting chunked data and flow-based content streaming. This class extends the base AbstractResponseDefinition to provide additional functionality specific to chunked or streamed responses. It can handle flow-based content delivery, manage chunk-wise delays, and supports various output formats such as OutputStream, Writer, or ServerSSESession.

Parameters

P

The type of the request body.

T

The type of the response data being streamed.

See also

Inheritors

Constructors

Link copied to clipboard
constructor(chunkFlow: <Error class: unknown class><T>? = null, chunks: List<T>? = null, delayBetweenChunks: <Error class: unknown class> = Duration.ZERO, contentType: <Error class: unknown class> = ContentType.Text.EventStream.withCharset(Charsets.UTF_8), httpStatus: <Error class: unknown class> = HttpStatusCode.OK, headers: <Error class: unknown class>.() -> Unit? = null, headerList: List<<Error class: unknown class><String, String>> = emptyList<Pair<String, String>>(), delay: <Error class: unknown class>)

Initializes a streaming response definition with the specified flow, chunk list, content type, HTTP status code, and headers.

Properties

Link copied to clipboard
open val chunkFlow: <Error class: unknown class><T>? = null

A Flow of chunks to be streamed as part of the response.

Link copied to clipboard
val chunks: List<T>? = null

A list of chunks representing the response data to be sent.

Link copied to clipboard
val contentType: <Error class: unknown class>?

The MIME type of the response content. Defaults to null.

Link copied to clipboard
open val delay: <Error class: unknown class>
Link copied to clipboard
val delayBetweenChunks: <Error class: unknown class>

Delay between the transmission of each chunk.

Link copied to clipboard
val headerList: List<<Error class: unknown class><String, String>>

A list of header key-value pairs to populate the response headers. Defaults to an empty list.

Link copied to clipboard
val headers: <Error class: unknown class>.() -> Unit?

A lambda function for configuring the response headers. Defaults to null.

Link copied to clipboard
val httpStatus: <Error class: unknown class>

The HTTP status code of the response. Defaults to HttpStatusCode.OK.