ktor-server-host-common / io.ktor.server.engine / BaseApplicationResponse

BaseApplicationResponse

abstract class BaseApplicationResponse : ApplicationResponse

Base class for implementing an ApplicationResponse

Exceptions

BodyLengthIsTooLong

class BodyLengthIsTooLong : IllegalStateException, CopyableThrowable<BodyLengthIsTooLong>

Content's actual body size doesn't match the provided one in Content-Length header

BodyLengthIsTooSmall

class BodyLengthIsTooSmall : IllegalStateException, CopyableThrowable<BodyLengthIsTooSmall>

Content's actual body size doesn't match the provided one in Content-Length header

InvalidHeaderForContent

class InvalidHeaderForContent : IllegalStateException, CopyableThrowable<InvalidHeaderForContent>

OutgoingContent is trying to set some header that is not allowed for this content type. For example, only upgrade content can set Upgrade header.

ResponseAlreadySentException

class ResponseAlreadySentException : IllegalStateException

Thrown when there was already response sent but we are trying to respond again

Constructors

<init>

BaseApplicationResponse(call: ApplicationCall)

Base class for implementing an ApplicationResponse

Properties

bufferPool

open val bufferPool: ObjectPool<ByteBuffer>

ByteBuffer pool

call

val call: ApplicationCall

cookies

open val cookies: ResponseCookies

pipeline

val pipeline: ApplicationSendPipeline

Functions

commitHeaders

fun commitHeaders(content: OutgoingContent): Unit

Commit header values and status and pass them to the underlying engine

push

open fun push(builder: ResponsePushBuilder): Unit

respondFromBytes

open suspend fun respondFromBytes(bytes: ByteArray): Unit

Respond with bytes content

respondFromChannel

open suspend fun respondFromChannel(readChannel: ByteReadChannel): Unit

Respond from readChannel

respondNoContent

open suspend fun respondNoContent(content: NoContent): Unit

Process response with no content

respondOutgoingContent

open suspend fun respondOutgoingContent(content: OutgoingContent): Unit

Process response outgoing content

respondUpgrade

abstract suspend fun respondUpgrade(upgrade: ProtocolUpgrade): Unit

Process upgrade response

respondWriteChannelContent

open suspend fun respondWriteChannelContent(content: WriteChannelContent): Unit

Process response content using OutgoingContent.WriteChannelContent.writeTo.

responseChannel

abstract suspend fun responseChannel(): ByteWriteChannel

Get response output channel

setStatus

abstract fun setStatus(statusCode: HttpStatusCode): Unit

Set underlying engine's response status

status

open fun status(): HttpStatusCode?
open fun status(value: HttpStatusCode): Unit

Companion Object Properties

EngineResponseAtributeKey

val EngineResponseAtributeKey: AttributeKey<BaseApplicationResponse>

Attribute key to access engine's response instance. This is engine internal API and should be never used by end-users unless you are writing your own engine implementation

Companion Object Functions

setupSendPipeline

fun setupSendPipeline(sendPipeline: ApplicationSendPipeline): Unit

Install an application-wide send pipeline interceptor into ApplicationSendPipeline.Engine phase to start response object processing via respondOutgoingContent