|
|
@ -8,6 +8,7 @@ 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.NetworkUtils |
|
|
|
import io.legado.app.utils.NetworkUtils |
|
|
|
import io.legado.app.utils.printOnDebug |
|
|
|
import io.legado.app.utils.printOnDebug |
|
|
|
|
|
|
|
import okhttp3.Interceptor |
|
|
|
import okhttp3.MediaType.Companion.toMediaType |
|
|
|
import okhttp3.MediaType.Companion.toMediaType |
|
|
|
import okhttp3.RequestBody.Companion.asRequestBody |
|
|
|
import okhttp3.RequestBody.Companion.asRequestBody |
|
|
|
import okhttp3.RequestBody.Companion.toRequestBody |
|
|
|
import okhttp3.RequestBody.Companion.toRequestBody |
|
|
@ -68,15 +69,18 @@ open class WebDav(val path: String, val authorization: Authorization) { |
|
|
|
}.getOrNull() |
|
|
|
}.getOrNull() |
|
|
|
} |
|
|
|
} |
|
|
|
private val webDavClient by lazy { |
|
|
|
private val webDavClient by lazy { |
|
|
|
val clientBuilder = okHttpClient.newBuilder() |
|
|
|
val authInterceptor = Interceptor { chain -> |
|
|
|
clientBuilder.addNetworkInterceptor { chain -> |
|
|
|
|
|
|
|
val request = chain.request() |
|
|
|
val request = chain.request() |
|
|
|
.newBuilder() |
|
|
|
.newBuilder() |
|
|
|
.addHeader(authorization.name, authorization.data) |
|
|
|
.header(authorization.name, authorization.data) |
|
|
|
.build() |
|
|
|
.build() |
|
|
|
chain.proceed(request) |
|
|
|
chain.proceed(request) |
|
|
|
} |
|
|
|
} |
|
|
|
clientBuilder.build() |
|
|
|
okHttpClient.newBuilder().run { |
|
|
|
|
|
|
|
interceptors().add(0, authInterceptor) |
|
|
|
|
|
|
|
addNetworkInterceptor(authInterceptor) |
|
|
|
|
|
|
|
build() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
val host: String? get() = url.host |
|
|
|
val host: String? get() = url.host |
|
|
|
|
|
|
|
|
|
|
|