From b98351a78b39f9c41e764ad0961e47dabb43fe5b Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 27 Apr 2022 08:12:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/lib/webdav/Authorization.kt | 2 ++ app/src/main/java/io/legado/app/lib/webdav/WebDav.kt | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/lib/webdav/Authorization.kt b/app/src/main/java/io/legado/app/lib/webdav/Authorization.kt index ad8d77011..b4e4fb17e 100644 --- a/app/src/main/java/io/legado/app/lib/webdav/Authorization.kt +++ b/app/src/main/java/io/legado/app/lib/webdav/Authorization.kt @@ -10,6 +10,8 @@ data class Authorization( val charset: Charset = StandardCharsets.ISO_8859_1 ) { + val name = "Authorization" + val data: String = Credentials.basic(username, password, charset) override fun toString(): String { diff --git a/app/src/main/java/io/legado/app/lib/webdav/WebDav.kt b/app/src/main/java/io/legado/app/lib/webdav/WebDav.kt index 084695117..decd7d00c 100644 --- a/app/src/main/java/io/legado/app/lib/webdav/WebDav.kt +++ b/app/src/main/java/io/legado/app/lib/webdav/WebDav.kt @@ -93,7 +93,7 @@ class WebDav(urlStr: String, val authorization: Authorization) { return kotlin.runCatching { okHttpClient.newCallResponseBody { url(url) - addHeader("Authorization", authorization.data) + addHeader(authorization.name, authorization.data) addHeader("Depth", "1") // 添加RequestBody对象,可以只返回的属性。如果设为null,则会返回全部属性 // 注意:尽量手动指定需要返回的属性。若返回全部属性,可能后由于Prop.java里没有该属性名,而崩溃。 @@ -161,7 +161,7 @@ class WebDav(urlStr: String, val authorization: Authorization) { okHttpClient.newCallResponse { url(url) method("MKCOL", null) - addHeader("Authorization", authorization.data) + addHeader(authorization.name, authorization.data) }.let { checkResult(it) } @@ -208,7 +208,7 @@ class WebDav(urlStr: String, val authorization: Authorization) { okHttpClient.newCallResponse { url(url) put(fileBody) - addHeader("Authorization", authorization.data) + addHeader(authorization.name, authorization.data) }.let { checkResult(it) } @@ -225,7 +225,7 @@ class WebDav(urlStr: String, val authorization: Authorization) { okHttpClient.newCallResponse { url(url) put(fileBody) - addHeader("Authorization", authorization.data) + addHeader(authorization.name, authorization.data) }.let { checkResult(it) } @@ -239,7 +239,7 @@ class WebDav(urlStr: String, val authorization: Authorization) { return kotlin.runCatching { okHttpClient.newCallResponseBody { url(url) - addHeader("Authorization", authorization.data) + addHeader(authorization.name, authorization.data) }.byteStream() }.getOrNull() }