Loading src/main/kotlin/at/bitfire/dav4jvm/DavCollection.kt +1 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ open class DavCollection @JvmOverloads constructor( httpClient: OkHttpClient, location: HttpUrl, log: Logger = Dav4jvm.log ): DavResource(httpClient, location, log) { ): DavResource(httpClient, location, null, log) { companion object { val SYNC_COLLECTION = Property.Name(XmlUtils.NS_WEBDAV, "sync-collection") Loading src/main/kotlin/at/bitfire/dav4jvm/DavResource.kt +27 −5 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import at.bitfire.dav4jvm.Response as DavResponse open class DavResource @JvmOverloads constructor( val httpClient: OkHttpClient, location: HttpUrl, var accessToken: String? = null, val log: Logger = Dav4jvm.log ) { Loading Loading @@ -94,6 +95,7 @@ open class DavResource @JvmOverloads constructor( */ @Throws(IOException::class, HttpException::class) fun options(callback: (davCapabilities: Set<String>, response: Response) -> Unit) { if (accessToken.isNullOrEmpty()) { httpClient.newCall(Request.Builder() .method("OPTIONS", null) .header("Content-Length", "0") Loading @@ -103,6 +105,17 @@ open class DavResource @JvmOverloads constructor( checkStatus(response) callback(HttpUtils.listHeader(response, "DAV").map { it.trim() }.toSet(), response) } } else { httpClient.newCall(Request.Builder() .method("OPTIONS", null) .header("Content-Length", "0") .header("Authorization", "Bearer $accessToken") .url(location) .build()).execute().use { response -> checkStatus(response) callback(HttpUtils.listHeader(response, "DAV").map { it.trim() }.toSet(), response) } } } /** Loading Loading @@ -431,11 +444,20 @@ open class DavResource @JvmOverloads constructor( serializer.endDocument() followRedirects { if (accessToken.isNullOrEmpty()) { httpClient.newCall(Request.Builder() .url(location) .method("PROPFIND", writer.toString().toRequestBody(MIME_XML)) .header("Depth", if (depth >= 0) depth.toString() else "infinity") .build()).execute() } else { httpClient.newCall(Request.Builder() .url(location) .method("PROPFIND", RequestBody.create(MIME_XML, writer.toString())) .header("Depth", if (depth >= 0) depth.toString() else "infinity") .header("Authorization", "Bearer $accessToken") .build()).execute() } }.use { processMultiStatus(it, callback) } Loading Loading
src/main/kotlin/at/bitfire/dav4jvm/DavCollection.kt +1 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ open class DavCollection @JvmOverloads constructor( httpClient: OkHttpClient, location: HttpUrl, log: Logger = Dav4jvm.log ): DavResource(httpClient, location, log) { ): DavResource(httpClient, location, null, log) { companion object { val SYNC_COLLECTION = Property.Name(XmlUtils.NS_WEBDAV, "sync-collection") Loading
src/main/kotlin/at/bitfire/dav4jvm/DavResource.kt +27 −5 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import at.bitfire.dav4jvm.Response as DavResponse open class DavResource @JvmOverloads constructor( val httpClient: OkHttpClient, location: HttpUrl, var accessToken: String? = null, val log: Logger = Dav4jvm.log ) { Loading Loading @@ -94,6 +95,7 @@ open class DavResource @JvmOverloads constructor( */ @Throws(IOException::class, HttpException::class) fun options(callback: (davCapabilities: Set<String>, response: Response) -> Unit) { if (accessToken.isNullOrEmpty()) { httpClient.newCall(Request.Builder() .method("OPTIONS", null) .header("Content-Length", "0") Loading @@ -103,6 +105,17 @@ open class DavResource @JvmOverloads constructor( checkStatus(response) callback(HttpUtils.listHeader(response, "DAV").map { it.trim() }.toSet(), response) } } else { httpClient.newCall(Request.Builder() .method("OPTIONS", null) .header("Content-Length", "0") .header("Authorization", "Bearer $accessToken") .url(location) .build()).execute().use { response -> checkStatus(response) callback(HttpUtils.listHeader(response, "DAV").map { it.trim() }.toSet(), response) } } } /** Loading Loading @@ -431,11 +444,20 @@ open class DavResource @JvmOverloads constructor( serializer.endDocument() followRedirects { if (accessToken.isNullOrEmpty()) { httpClient.newCall(Request.Builder() .url(location) .method("PROPFIND", writer.toString().toRequestBody(MIME_XML)) .header("Depth", if (depth >= 0) depth.toString() else "infinity") .build()).execute() } else { httpClient.newCall(Request.Builder() .url(location) .method("PROPFIND", RequestBody.create(MIME_XML, writer.toString())) .header("Depth", if (depth >= 0) depth.toString() else "infinity") .header("Authorization", "Bearer $accessToken") .build()).execute() } }.use { processMultiStatus(it, callback) } Loading