ktor-server-test-host / io.ktor.server.testing / TestApplicationResponse

TestApplicationResponse

class TestApplicationResponse : BaseApplicationResponse, CoroutineScope

Represents test call response received from server

Constructors

<init>

TestApplicationResponse(call: TestApplicationCall, readResponse: Boolean = false)

Represents test call response received from server

Properties

byteContent

var byteContent: ByteArray?

Response body byte content. Could be blocking. Remains null until response appears.

content

val content: String?

Response body text content. Could be blocking. Remains null until response appears.

headers

val headers: ResponseHeaders

Functions

awaitWebSocket

fun awaitWebSocket(durationMillis: Long): Unit

Wait for websocket session completion

fun awaitWebSocket(duration: Duration): Unit

contentChannel

fun contentChannel(): ByteReadChannel?

Response body content channel

flush

suspend fun flush(): Unit

Await for response job completion

respondOutgoingContent

suspend fun respondOutgoingContent(content: OutgoingContent): Unit

respondUpgrade

suspend fun respondUpgrade(upgrade: ProtocolUpgrade): Unit

responseChannel

suspend fun responseChannel(): ByteWriteChannel

setStatus

fun setStatus(statusCode: HttpStatusCode): Unit

websocketChannel

fun websocketChannel(): ByteReadChannel?

Websocket session's channel

Extension Functions

awaitWebSocket

fun TestApplicationResponse.awaitWebSocket(duration: Duration): Unit

Wait for websocket session completion

contentType

fun TestApplicationResponse.contentType(): ContentType

Return parsed content type from the test response