Skip to content

Commit

Permalink
1.降低OauthClientInterceptor中的headers优先级,不再强行替换所有已存在的请求头。
Browse files Browse the repository at this point in the history
2.把accessToken从OauthProvider的headers中拆分。
  • Loading branch information
Tears丶残阳 committed May 16, 2023
1 parent 414b5db commit 88c5f9d
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions http/src/main/kotlin/cn/numeron/retrofit/FileConverter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ class FileConverter : Converter<ResponseBody, File> {
return if (responseBody is FileResponseBody) {
responseBody.file
} else try {
getFile(DELEGATE_FIELD.get(responseBody) as ResponseBody)
val declaredField = responseBody::class.java.getDeclaredField("delegate")
declaredField.isAccessible = true
val delegate = declaredField.get(responseBody) as ResponseBody
getFile(delegate)
} catch (throwable: Throwable) {
throw RuntimeException("响应体中没有记录文件信息!或者没有使用Tag标记File类型的参数!", throwable)
}
Expand All @@ -42,12 +45,4 @@ class FileConverter : Converter<ResponseBody, File> {

}

companion object {
private val DELEGATE_FIELD by lazy {
ResponseBody::class.java.getDeclaredField("delegate").apply {
isAccessible = true
}
}
}

}

0 comments on commit 88c5f9d

Please sign in to comment.