Package io.ktor.response

Types

ApplicationResponse

interface ApplicationResponse

Represents server’s response

ApplicationSendPipeline

open class ApplicationSendPipeline : 
    Pipeline<Any, ApplicationCall>

Server response send pipeline

DefaultResponsePushBuilder

class DefaultResponsePushBuilder : ResponsePushBuilder

HTTP/2 push builder

ResponseCookies

class ResponseCookies

Server’s response cookies

ResponseHeaders

abstract class ResponseHeaders

Server’s response headers

ResponsePushBuilder

interface ResponsePushBuilder

HTTP/2 push builder interface

Functions

cacheControl

fun ApplicationResponse.cacheControl(
    value: CacheControl
): Unit

Append response Cache-Control HTTP header value

fun HeadersBuilder.cacheControl(value: CacheControl): Unit

Append Cache-Control HTTP header value

contentRange

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

Append ‘Content-Range` header with specified range and fullLength

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

defaultTextContentType

fun ApplicationCall.defaultTextContentType(
    contentType: ContentType?
): ContentType

Creates a default ContentType based on the given contentType and current call

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

respond

suspend fun ApplicationCall.respond(message: Any): Unit

Sends a message as a response

suspend fun ApplicationCall.respond(
    status: HttpStatusCode,
    message: Any
): Unit

Sets status and sends a message as a response

respondBytes

suspend fun ApplicationCall.respondBytes(
    contentType: ContentType? = null,
    status: HttpStatusCode? = null,
    provider: suspend () -> ByteArray
): Unit

Responds to a client with a raw bytes response, using specified provider to build a byte array

suspend fun ApplicationCall.respondBytes(
    bytes: ByteArray,
    contentType: ContentType? = null,
    status: HttpStatusCode? = null,
    configure: OutgoingContent.() -> Unit = {}
): Unit

Responds to a client with a raw bytes response, using specified bytes

respondFile

suspend fun ApplicationCall.respondFile(
    baseDir: File,
    fileName: String,
    configure: OutgoingContent.() -> Unit = {}
): Unit

Responds to a client with a contents of a file with the name fileName in the baseDir folder

suspend fun ApplicationCall.respondFile(
    file: File,
    configure: OutgoingContent.() -> Unit = {}
): Unit

Responds to a client with a contents of a file

respondOutputStream

suspend fun ApplicationCall.respondOutputStream(
    contentType: ContentType? = null,
    status: HttpStatusCode? = null,
    producer: suspend OutputStream.() -> Unit
): Unit

Respond with binary content producer.

respondRedirect

suspend fun ApplicationCall.respondRedirect(
    url: String,
    permanent: Boolean = false
): Unit

Responds to a client with a 301 Moved Permanently or 302 Found redirect

suspend fun ApplicationCall.respondRedirect(
    permanent: Boolean = false,
    block: URLBuilder.() -> Unit
): Unit

Responds to a client with a 301 Moved Permanently or 302 Found redirect. Unlike the other respondRedirect it provides a way to build URL based on current call using block function

respondText

suspend fun ApplicationCall.respondText(
    text: String,
    contentType: ContentType? = null,
    status: HttpStatusCode? = null,
    configure: OutgoingContent.() -> Unit = {}
): Unit

Responds to a client with a plain text response, using specified text

suspend fun ApplicationCall.respondText(
    contentType: ContentType? = null,
    status: HttpStatusCode? = null,
    provider: suspend () -> String
): Unit

Responds to a client with a plain text response, using specified provider to build a text

respondTextWriter

suspend fun ApplicationCall.respondTextWriter(
    contentType: ContentType? = null,
    status: HttpStatusCode? = null,
    writer: suspend Writer.() -> Unit
): Unit

Respond with text content writer.

respondWrite

suspend fun ApplicationCall.respondWrite(
    contentType: ContentType? = null,
    status: HttpStatusCode? = null,
    writer: suspend Writer.() -> Unit
): Unit