Package io.ktor.server.response

Types

Link copied to clipboard
interface ApplicationResponse

Represents server's response

Link copied to clipboard
open class ApplicationSendPipeline(developmentMode: Boolean)

Server response send pipeline

Link copied to clipboard
class DefaultResponsePushBuilder(method: <ERROR CLASS>, url: <ERROR CLASS>, headers: <ERROR CLASS>, versions: List<<ERROR CLASS>>) : ResponsePushBuilder

HTTP/2 push builder

Link copied to clipboard
class ResponseCookies(response: ApplicationResponse, secureTransport: Boolean)

Server's response cookies

Link copied to clipboard
abstract class ResponseHeaders

Server's response headers

Link copied to clipboard
interface ResponsePushBuilder

HTTP/2 push builder interface

Link copied to clipboard
annotation class UseHttp2Push

HTTP/2 push is no longer supported by Chrome web browser. Other browsers may discard it at some point. With such browsers, HTTP/2 push will be disabled, therefore using this plugin is safe but it will have no effect. On the other hand, this plugin is not deprecated and generally it is still allowed to use it, so feel free to opt-in this annotation to eliminate this warning, if you are sure that you need it. For example, it makes sense to use with a non-browser client that for sure supports HTTP/2 push.

Functions

Link copied to clipboard
fun <ERROR CLASS>.cacheControl(value: <ERROR CLASS>)

Append Cache-Control HTTP header value

fun ApplicationResponse.cacheControl(value: <ERROR CLASS>)

Append response Cache-Control HTTP header value

Link copied to clipboard
fun <ERROR CLASS>.contentRange(range: LongRange?, fullLength: Long? = null, unit: String = RangeUnits.Bytes.unitToken)

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

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

Append response Content-Range header with specified range and fullLength

Link copied to clipboard
fun ApplicationCall.defaultTextContentType(contentType: <ERROR CLASS>?): <ERROR CLASS>

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

Link copied to clipboard
fun ApplicationResponse.etag(value: String)

Append response E-Tag HTTP header value

Link copied to clipboard
fun HeadersBuilder.expires(expires: LocalDateTime)

Set 'Expires` header value from expires

fun ApplicationResponse.expires(value: LocalDateTime)

Append response Expires HTTP header value

Link copied to clipboard
fun ApplicationResponse.header(name: String, value: Int)

Append HTTP response header with integer numeric value

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

Append HTTP response header with long integer numeric value

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

Append HTTP response header with string value

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

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

Link copied to clipboard
fun HeadersBuilder.lastModified(dateTime: ZonedDateTime)

Set 'Last-Modified` header value from dateTime

fun ApplicationResponse.lastModified(dateTime: ZonedDateTime)

Append response Last-Modified HTTP header value from dateTime

Link copied to clipboard
@JvmName(name = "respondWithType")
inline suspend fun <T : Any> ApplicationCall.respond(message: T)

Sends a message as a response

@JvmName(name = "respondWithType")
inline suspend fun <T : Any> ApplicationCall.respond(status: <ERROR CLASS>, message: T)

Sets status and sends a message as a response

Link copied to clipboard
suspend fun ApplicationCall.respondBytes(contentType: <ERROR CLASS>? = null, status: <ERROR CLASS>? = null, provider: suspend () -> ByteArray)

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

suspend fun ApplicationCall.respondBytes(bytes: ByteArray, contentType: <ERROR CLASS>? = null, status: <ERROR CLASS>? = null, configure: <ERROR CLASS>.() -> Unit = {})

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

Link copied to clipboard
suspend fun ApplicationCall.respondBytesWriter(contentType: <ERROR CLASS>? = null, status: <ERROR CLASS>? = null, contentLength: Long? = null, producer: suspend <ERROR CLASS>.() -> Unit)

Respond with binary content producer.

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

Responds to a client with a contents of a file

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

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

Link copied to clipboard
suspend fun ApplicationCall.respondOutputStream(contentType: ContentType? = null, status: HttpStatusCode? = null, producer: suspend OutputStream.() -> Unit)
suspend fun ApplicationCall.respondOutputStream(contentType: ContentType? = null, status: HttpStatusCode? = null, contentLength: Long? = null, producer: suspend OutputStream.() -> Unit)

Respond with binary content producer.

Link copied to clipboard
inline suspend fun ApplicationCall.respondRedirect(permanent: Boolean = false, block: <ERROR CLASS>.() -> 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

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

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

Link copied to clipboard
suspend fun ApplicationCall.respondText(contentType: <ERROR CLASS>? = null, status: <ERROR CLASS>? = null, provider: suspend () -> String)

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

suspend fun ApplicationCall.respondText(text: String, contentType: <ERROR CLASS>? = null, status: <ERROR CLASS>? = null, configure: <ERROR CLASS>.() -> Unit = {})

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

Link copied to clipboard
suspend fun ApplicationCall.respondTextWriter(contentType: ContentType? = null, status: HttpStatusCode? = null, writer: suspend Writer.() -> Unit)
suspend fun ApplicationCall.respondTextWriter(contentType: ContentType? = null, status: HttpStatusCode? = null, contentLength: Long? = null, writer: suspend Writer.() -> Unit)

Respond with text content writer.

Properties

Link copied to clipboard
var ApplicationResponse.responseType: <ERROR CLASS>?

Type of the response object that was passed in respond function. Can be useful for custom serializations.