Package-level declarations

Types

Link copied to clipboard

A server's response. To learn how to send responses inside route handlers, see Sending responses.

Link copied to clipboard
open class ApplicationSendPipeline(val developmentMode: Boolean = false) : Pipeline<Any, PipelineCall>

Server response send pipeline.

Link copied to clipboard
class DefaultResponsePushBuilder(var method: HttpMethod = HttpMethod.Get, val url: URLBuilder = URLBuilder(), val headers: HeadersBuilder = HeadersBuilder(), versions: List<Version> = emptyList()) : ResponsePushBuilder

An HTTP/2 push builder.

Link copied to clipboard

A server's response that is used in ApplicationPlugin. To learn how to send responses inside route handlers, see Sending responses.

Link copied to clipboard

Server's response cookies.

Link copied to clipboard
abstract class ResponseHeaders

Server's response headers.

Link copied to clipboard

An HTTP/2 push builder interface.

Link copied to clipboard
annotation class UseHttp2Push

HTTP/2 push is no longer supported by the 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.

Properties

Link copied to clipboard

A type of response object that is passed in the respond function. Can be useful for custom serializations.

Functions

Link copied to clipboard
fun ResponseHeaders.appendIfAbsent(name: String, value: String, safeOnly: Boolean = true)

Appends a response header with the specified name and value if this is no header with name yet.

Link copied to clipboard

Appends the Cache-Control header with the specified value to a response.

Link copied to clipboard
fun HeadersBuilder.contentRange(range: LongRange?, fullLength: Long? = null, unit: String = RangeUnits.Bytes.unitToken)
fun ApplicationResponse.contentRange(range: LongRange?, fullLength: Long? = null, unit: RangeUnits)
fun ApplicationResponse.contentRange(range: LongRange?, fullLength: Long? = null, unit: String = RangeUnits.Bytes.unitToken)

Appends the Content-Range header with the specified range and fullLength to a response.

Link copied to clipboard

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

Link copied to clipboard

Appends the E-Tag header with the specified value to a response.

Link copied to clipboard

Set 'Expires` header value from expires

Append response Expires HTTP header value

Link copied to clipboard

Appends a header with the specified name and value to a response.

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

Link copied to clipboard

Set 'Last-Modified` header value from dateTime

Append response Last-Modified HTTP header value from dateTime

Link copied to clipboard
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: HttpStatusCode, message: T)

Sends a message as a response with the specified status code.

suspend fun ApplicationCall.respond(status: HttpStatusCode, message: Any?, messageType: TypeInfo)

Sends a message of type messageType as a response with the specified status code.

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

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

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

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

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

Respond with a 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
inline suspend fun <T> ApplicationCall.respondNullable(message: T)

Sends a message as a response.

inline suspend fun <T> ApplicationCall.respondNullable(status: HttpStatusCode, message: T)

Sends a message as a response with the specified status code.

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
suspend fun ApplicationCall.respondRedirect(url: Url, permanent: Boolean = false)
suspend fun ApplicationCall.respondRedirect(url: String, permanent: Boolean = false)

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

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

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

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

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

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

Responds to a client with a plain text response.

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.