|
|
@ -1,6 +1,6 @@ |
|
|
|
package io.legado.app.lib.webdav |
|
|
|
package io.legado.app.lib.webdav |
|
|
|
|
|
|
|
|
|
|
|
import io.legado.app.help.http.newCall |
|
|
|
import io.legado.app.help.http.newCallResponseBody |
|
|
|
import io.legado.app.help.http.okHttpClient |
|
|
|
import io.legado.app.help.http.okHttpClient |
|
|
|
import io.legado.app.help.http.text |
|
|
|
import io.legado.app.help.http.text |
|
|
|
import io.legado.app.utils.printOnDebug |
|
|
|
import io.legado.app.utils.printOnDebug |
|
|
@ -92,7 +92,7 @@ class WebDav(urlStr: String) { |
|
|
|
val auth = HttpAuth.auth |
|
|
|
val auth = HttpAuth.auth |
|
|
|
if (url != null && auth != null) { |
|
|
|
if (url != null && auth != null) { |
|
|
|
return kotlin.runCatching { |
|
|
|
return kotlin.runCatching { |
|
|
|
okHttpClient.newCall { |
|
|
|
okHttpClient.newCallResponseBody { |
|
|
|
url(url) |
|
|
|
url(url) |
|
|
|
addHeader("Authorization", Credentials.basic(auth.user, auth.pass)) |
|
|
|
addHeader("Authorization", Credentials.basic(auth.user, auth.pass)) |
|
|
|
addHeader("Depth", "1") |
|
|
|
addHeader("Depth", "1") |
|
|
@ -152,7 +152,7 @@ class WebDav(urlStr: String) { |
|
|
|
if (url != null && auth != null) { |
|
|
|
if (url != null && auth != null) { |
|
|
|
//防止报错 |
|
|
|
//防止报错 |
|
|
|
return kotlin.runCatching { |
|
|
|
return kotlin.runCatching { |
|
|
|
okHttpClient.newCall { |
|
|
|
okHttpClient.newCallResponseBody { |
|
|
|
url(url) |
|
|
|
url(url) |
|
|
|
method("MKCOL", null) |
|
|
|
method("MKCOL", null) |
|
|
|
addHeader("Authorization", Credentials.basic(auth.user, auth.pass)) |
|
|
|
addHeader("Authorization", Credentials.basic(auth.user, auth.pass)) |
|
|
@ -198,7 +198,7 @@ class WebDav(urlStr: String) { |
|
|
|
val auth = HttpAuth.auth |
|
|
|
val auth = HttpAuth.auth |
|
|
|
if (url != null && auth != null) { |
|
|
|
if (url != null && auth != null) { |
|
|
|
return kotlin.runCatching { |
|
|
|
return kotlin.runCatching { |
|
|
|
okHttpClient.newCall { |
|
|
|
okHttpClient.newCallResponseBody { |
|
|
|
url(url) |
|
|
|
url(url) |
|
|
|
put(fileBody) |
|
|
|
put(fileBody) |
|
|
|
addHeader("Authorization", Credentials.basic(auth.user, auth.pass)) |
|
|
|
addHeader("Authorization", Credentials.basic(auth.user, auth.pass)) |
|
|
@ -215,7 +215,7 @@ class WebDav(urlStr: String) { |
|
|
|
val auth = HttpAuth.auth |
|
|
|
val auth = HttpAuth.auth |
|
|
|
if (url != null && auth != null) { |
|
|
|
if (url != null && auth != null) { |
|
|
|
return kotlin.runCatching { |
|
|
|
return kotlin.runCatching { |
|
|
|
okHttpClient.newCall { |
|
|
|
okHttpClient.newCallResponseBody { |
|
|
|
url(url) |
|
|
|
url(url) |
|
|
|
put(fileBody) |
|
|
|
put(fileBody) |
|
|
|
addHeader("Authorization", Credentials.basic(auth.user, auth.pass)) |
|
|
|
addHeader("Authorization", Credentials.basic(auth.user, auth.pass)) |
|
|
@ -230,7 +230,7 @@ class WebDav(urlStr: String) { |
|
|
|
val auth = HttpAuth.auth |
|
|
|
val auth = HttpAuth.auth |
|
|
|
if (url != null && auth != null) { |
|
|
|
if (url != null && auth != null) { |
|
|
|
return kotlin.runCatching { |
|
|
|
return kotlin.runCatching { |
|
|
|
okHttpClient.newCall { |
|
|
|
okHttpClient.newCallResponseBody { |
|
|
|
url(url) |
|
|
|
url(url) |
|
|
|
addHeader("Authorization", Credentials.basic(auth.user, auth.pass)) |
|
|
|
addHeader("Authorization", Credentials.basic(auth.user, auth.pass)) |
|
|
|
}.byteStream() |
|
|
|
}.byteStream() |
|
|
|