From b02fa75c1e051bc6cadfb5557dc1eaa88c3b78ea Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 24 Apr 2022 23:22:46 +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 --- .../main/java/io/legado/app/lib/webdav/WebDav.kt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) 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 fa0f66a4a..90dfe149c 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 @@ -157,11 +157,13 @@ class WebDav(urlStr: String, val authorization: Authorization) { //防止报错 return kotlin.runCatching { if (!exists()) { - okHttpClient.newCallResponseBody { + okHttpClient.newCallResponse { url(url) method("MKCOL", null) addHeader("Authorization", authorization.data) - }.close() + }.body?.string()?.let { + Log.d("webDav/makAsDir", it) + } } }.onFailure { AppLog.put(it.localizedMessage) @@ -207,7 +209,7 @@ class WebDav(urlStr: String, val authorization: Authorization) { put(fileBody) addHeader("Authorization", authorization.data) }.body?.string()?.let { - Log.d("webDav", it) + Log.d("webDav/upload", it) } }.onFailure { it.printOnDebug() @@ -219,11 +221,15 @@ class WebDav(urlStr: String, val authorization: Authorization) { val fileBody = byteArray.toRequestBody(contentType.toMediaType()) val url = httpUrl ?: return false return kotlin.runCatching { - okHttpClient.newCallResponseBody { + okHttpClient.newCallResponse { url(url) put(fileBody) addHeader("Authorization", authorization.data) - }.close() + }.body?.string()?.let { + Log.d("webDav/upload", it) + } + }.onFailure { + it.printOnDebug() }.isSuccess }