HttpPlainText

预计阅读时间: 1 分钟

This feature processes the request content as plain text of a specified charset by defaultCharset. Also, it will process the response content as plain text too.

本特性在 io.ktor.client.features.HttpPlainText 类中定义,无需任何额外构件。

Install

val client = HttpClient(HttpClientEngine) {
    install(HttpPlainText) {
        defaultCharset = Charsets.UTF_8
    }
}

Bear in mind that the default charset is the JVM’s charset that could be different between systems.
That’s why it is recommended to specify the default charset.