pull/1827/head
kunfei 3 years ago
parent 3be7aab2be
commit b98351a78b
  1. 2
      app/src/main/java/io/legado/app/lib/webdav/Authorization.kt
  2. 10
      app/src/main/java/io/legado/app/lib/webdav/WebDav.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 {

@ -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()
}

Loading…
Cancel
Save