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

TestApplicationRequest

class TestApplicationRequest : BaseApplicationRequest, CoroutineScope

Represents a test application request

Constructors

<init>

TestApplicationRequest(call: TestApplicationCall, closeRequest: Boolean, method: HttpMethod = HttpMethod.Get, uri: String = "/", version: String = "HTTP/1.1")

Represents a test application request

Properties

bodyChannel

var bodyChannel: ByteReadChannel

Request body channel

cookies

val cookies: RequestCookies

headers

val headers: Headers

local

val local: RequestConnectionPoint

method

var method: HttpMethod

HTTP method to be sent or executed

protocol

var protocol: String

HTTP protocol to be used or was used

queryParameters

val queryParameters: Parameters

uri

var uri: String

HTTP url to sent request to or was sent to

version

var version: String

HTTP version to sent or executed

Functions

addHeader

fun addHeader(name: String, value: String): Unit

Add HTTP request header

receiveChannel

fun receiveChannel(): ByteReadChannel

Extension Functions

setBody

fun TestApplicationRequest.setBody(value: String): Unit

Set HTTP request body text content

fun TestApplicationRequest.setBody(value: ByteArray): Unit

Set HTTP request body bytes

fun TestApplicationRequest.setBody(boundary: String, parts: List<PartData>): Unit

Set multipart HTTP request body