Package io.ktor.client.engine.mock
Types
Link copied to clipboard
HttpClientEngine for writing tests without network.
Link copied to clipboard
Link copied to clipboard
typealias MockRequestHandler = suspend MockRequestHandleScope.(request: HttpRequestData) -> HttpResponseData
Content copied to clipboard
Single HttpClientCall to HttpResponse mapper.
Link copied to clipboard
Scope for MockRequestHandler.
Functions
Link copied to clipboard
fun MockRequestHandleScope.respond(content: ByteReadChannel, status: HttpStatusCode = HttpStatusCode.OK, headers: Headers = headersOf()): HttpResponseData
Content copied to clipboard
Send response with specified ByteReadChannel, status and headers.
fun MockRequestHandleScope.respond(content: ByteArray, status: HttpStatusCode = HttpStatusCode.OK, headers: Headers = headersOf()): HttpResponseData
Content copied to clipboard
fun MockRequestHandleScope.respond(content: String, status: HttpStatusCode = HttpStatusCode.OK, headers: Headers = headersOf()): HttpResponseData
Content copied to clipboard
Link copied to clipboard
Send HttpStatusCode.BadRequest response.
Link copied to clipboard
fun MockRequestHandleScope.respondError(status: HttpStatusCode, content: String = status.description, headers: Headers = headersOf()): HttpResponseData
Content copied to clipboard
Send error response.
Link copied to clipboard
fun MockRequestHandleScope.respondOk(content: String = ""): HttpResponseData
Content copied to clipboard
Send ok response.
Link copied to clipboard
fun MockRequestHandleScope.respondRedirect(location: String = ""): HttpResponseData
Content copied to clipboard
Respond redirect with location in Location header.
Link copied to clipboard
Link copied to clipboard