UserAgent

预计阅读时间: 1 分钟

This feature add User-Agent header to requests.

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

Install

val client = HttpClient() {

    // full configuration
    install(UserAgent) {
        agent = "ktor"
    }

    // short version for browser-like user agent
    BrowserUserAgent()

    // short version for curl-like user agent
    CurlUserAgent()
}