User Agent

预计阅读时间: 1 分钟

This feature adds a User-Agent header to requests.

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

Install

val client = HttpClient() {

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

    // Shortcut for the browser-like user agent.
    BrowserUserAgent()

    // Shortcut for the curl-like user agent.
    CurlUserAgent()
}