BaseApplicationResponse

abstract class BaseApplicationResponse : ApplicationResponse

Base class for implementing an ApplicationResponse

Exceptions

BodyLengthIsTooLong

class BodyLengthIsTooLong : IllegalStateException

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

BodyLengthIsTooSmall

class BodyLengthIsTooSmall : IllegalStateException

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

InvalidHeaderForContent

class InvalidHeaderForContent : IllegalStateException

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

open val call: ApplicationCall

ApplicationCall instance this ApplicationResponse is attached to

cookies

open val cookies: ResponseCookies

Cookies for this response

pipeline

Pipeline for sending content

Inherited Properties

headers

abstract val headers: ResponseHeaders

Headers for this response

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

Produces HTTP/2 push from server to client or sets HTTP/1.x hint header or does nothing. Exact behaviour is up to engine implementation.

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?

Currently set status code for this response, or null if none was set

open fun status(value: HttpStatusCode): Unit

Set status for this response

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(application: Application): Unit
fun setupSendPipeline(
    sendPipeline: ApplicationSendPipeline
): Unit

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

Extension Functions

cacheControl

fun ApplicationResponse.cacheControl(
    value: CacheControl
): Unit

Append response Cache-Control HTTP header value

contentRange

fun ApplicationResponse.contentRange(
    range: LongRange?,
    fullLength: Long? = null,
    unit: RangeUnits
): Unit
fun ApplicationResponse.contentRange(
    range: LongRange?,
    fullLength: Long? = null,
    unit: String = RangeUnits.Bytes.unitToken
): Unit

Append response Content-Range header with specified range and fullLength

etag

fun ApplicationResponse.etag(value: String): Unit

Append response E-Tag HTTP header value

expires

fun ApplicationResponse.expires(value: LocalDateTime): Unit

Append response Expires HTTP header value

header

fun ApplicationResponse.header(
    name: String,
    value: String
): Unit

Append HTTP response header with string value

fun ApplicationResponse.header(
    name: String,
    value: Int
): Unit

Append HTTP response header with integer numeric value

fun ApplicationResponse.header(
    name: String,
    value: Long
): Unit

Append HTTP response header with long integer numeric value

fun ApplicationResponse.header(
    name: String,
    date: Temporal
): Unit

Append HTTP response header with temporal date (date, time and so on)

lastModified

fun ApplicationResponse.lastModified(
    dateTime: ZonedDateTime
): Unit

Append response Last-Modified HTTP header value from dateTime

link

fun ApplicationResponse.link(header: LinkHeader): Unit

Append Link header to HTTP response

fun ApplicationResponse.link(
    uri: String,
    vararg rel: String
): Unit

Append Link header to HTTP response with specified uri and rel

Inheritors

NettyApplicationResponse

abstract class NettyApplicationResponse : 
    BaseApplicationResponse

ServletApplicationResponse

abstract class ServletApplicationResponse : 
    BaseApplicationResponse

TestApplicationResponse

class TestApplicationResponse : 
    BaseApplicationResponse,
    CoroutineScope

Represents test call response received from server