diff --git a/app/src/main/java/io/legado/app/help/http/OkHttpUtils.kt b/app/src/main/java/io/legado/app/help/http/OkHttpUtils.kt index 4dec4bf3e..f87d58aab 100644 --- a/app/src/main/java/io/legado/app/help/http/OkHttpUtils.kt +++ b/app/src/main/java/io/legado/app/help/http/OkHttpUtils.kt @@ -119,4 +119,8 @@ fun Request.Builder.postJson(json: String?) { val requestBody = json.toRequestBody("application/json; charset=UTF-8".toMediaType()) post(requestBody) } +} + +fun Request.Builder.mkCol() { + method("MKCOL", null) } \ No newline at end of file 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 51f52cc9a..8d20fdd17 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 @@ -1,5 +1,6 @@ package io.legado.app.lib.webdav +import io.legado.app.help.http.mkCol import io.legado.app.help.http.newCall import io.legado.app.help.http.okHttpClient import io.legado.app.help.http.text @@ -148,9 +149,9 @@ class WebDav(urlStr: String) { return kotlin.runCatching { okHttpClient.newCall { url(url) - method("MKCOL", null) + mkCol() addHeader("Authorization", Credentials.basic(auth.user, auth.pass)) - } + }.close() }.isSuccess } return false @@ -192,7 +193,7 @@ class WebDav(urlStr: String) { url(url) put(fileBody) addHeader("Authorization", Credentials.basic(auth.user, auth.pass)) - } + }.close() return true } return false @@ -208,7 +209,7 @@ class WebDav(urlStr: String) { url(url) put(fileBody) addHeader("Authorization", Credentials.basic(auth.user, auth.pass)) - } + }.close() return true } return false