gpt4 book ai didi

kotlin - Kotlin OkHttp3使用 'of(Map): Headers'是错误。功能移至扩展

转载 作者:行者123 更新时间:2023-12-02 13:19:14 24 4
gpt4 key购买 nike

下面的代码给出了错误:使用'of(Map):Headers'是一个错误。功能移至扩展名。

val mapH = mapOf (Pair("Content-Disposition",
"file; filename=\"$encodedFileName\""),
Pair("Content-Transfer-Encoding",
"binary"))

val headers = Headers.of (mapH)

阅读了 https://square.github.io/okhttp/upgrading_to_okhttp_4/#extension-functions的文档后,我尝试了:
      val headers = headersOf(mapH)
and also
val headers = mapH.toHeaders()

并得到以下错误:未解析的引用:headersOf和toHeaders。为什么呢

最佳答案

试试这个:

import okhttp3.Headers.Companion.toHeaders

关于kotlin - Kotlin OkHttp3使用 'of(Map<String, String>): Headers'是错误。功能移至扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60283974/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com