pull/981/head
gedoor 4 years ago
parent 907599b7d2
commit 18828dd1db
  1. 10
      app/src/main/java/io/legado/app/lib/webdav/WebDav.kt

@ -190,12 +190,13 @@ class WebDav(urlStr: String) {
val url = httpUrl val url = httpUrl
val auth = HttpAuth.auth val auth = HttpAuth.auth
if (url != null && auth != null) { if (url != null && auth != null) {
return kotlin.runCatching {
okHttpClient.newCall { okHttpClient.newCall {
url(url) url(url)
put(fileBody) put(fileBody)
addHeader("Authorization", Credentials.basic(auth.user, auth.pass)) addHeader("Authorization", Credentials.basic(auth.user, auth.pass))
}.close() }.close()
return true }.isSuccess
} }
return false return false
} }
@ -206,12 +207,13 @@ class WebDav(urlStr: String) {
val url = httpUrl val url = httpUrl
val auth = HttpAuth.auth val auth = HttpAuth.auth
if (url != null && auth != null) { if (url != null && auth != null) {
return kotlin.runCatching {
okHttpClient.newCall { okHttpClient.newCall {
url(url) url(url)
put(fileBody) put(fileBody)
addHeader("Authorization", Credentials.basic(auth.user, auth.pass)) addHeader("Authorization", Credentials.basic(auth.user, auth.pass))
}.close() }.close()
return true }.isSuccess
} }
return false return false
} }
@ -220,10 +222,12 @@ class WebDav(urlStr: String) {
val url = httpUrl val url = httpUrl
val auth = HttpAuth.auth val auth = HttpAuth.auth
if (url != null && auth != null) { if (url != null && auth != null) {
return okHttpClient.newCall { return kotlin.runCatching {
okHttpClient.newCall {
url(url) url(url)
addHeader("Authorization", Credentials.basic(auth.user, auth.pass)) addHeader("Authorization", Credentials.basic(auth.user, auth.pass))
}.byteStream() }.byteStream()
}.getOrNull()
} }
return null return null
} }

Loading…
Cancel
Save