OutputStreamContent

class OutputStreamContent : WriteChannelContent

OutgoingContent to respond with OutputStream. The stream would be automatically closed after body finish.

Constructors

<init>

OutputStreamContent(
    body: suspend OutputStream.() -> Unit,
    contentType: ContentType,
    status: HttpStatusCode? = null)

OutgoingContent to respond with OutputStream. The stream would be automatically closed after body finish.

Properties

contentType

val contentType: ContentType

Specifies ContentType for this resource.

status

val status: HttpStatusCode?

Status code to set when sending this content

Functions

writeTo

suspend fun writeTo(channel: ByteWriteChannel): Unit

Receives channel provided by the engine and writes all data to it

Extension Properties

caching

Gets or sets CacheControl instance as an extension property on this content

defaultVersions

val OutgoingContent.defaultVersions: List<Version>

Retrieves LastModified and ETag versions from this OutgoingContent headers

versions

Gets or sets list of Version instances as an extension property on this content

Extension Functions

toByteArray

suspend fun OutgoingContent.toByteArray(): ByteArray

toByteReadPacket

suspend fun OutgoingContent.toByteReadPacket(): ByteReadPacket

wrapHeaders

fun OutgoingContent.wrapHeaders(
    block: (Headers) -> Headers
): OutgoingContent

Generates a new OutgoingContent of the same abstract type but with OutgoingContent.headers transformed by the specified block.