Cookies

预计阅读时间:1分钟

此功能可在通话之间保留cookie或强制特定cookie.

此功能是在io.ktor.client.features.cookies方法中io.ktor.client.features.cookies ,不需要其他工件.

Installation

val client = HttpClient() {
    install(HttpCookies) {
        // Will keep an in-memory map with all the cookies from previous requests.
        storage = AcceptAllCookiesStorage()

        // Will ignore Set-Cookie and will send the specified cookies.
        storage = ConstantCookieStorage(Cookie("mycookie1", "value"), Cookie("mycookie2", "value"))
    }
}

client.cookies("mydomain.com")

by  ICOPY.SITE