Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 9aafb6c8 authored by Ricki Hirner's avatar Ricki Hirner
Browse files

[no ci] [WIP] Add tests

parent ace9b210
Loading
Loading
Loading
Loading
+30 −24
Original line number Diff line number Diff line
@@ -455,29 +455,6 @@ open class DavResource @JvmOverloads constructor(
        }
    }

    /**
     * Sends a SEARCH request with the given body to the server.
     *
     * Follows up to [MAX_REDIRECTS] redirects.
     *
     * @param search    search request body (XML format)
     * @param callback  called for every XML response element in the Multi-Status response
     *
     * @throws IOException on I/O error
     * @throws HttpException on HTTP error
     * @throws DavException on WebDAV error (like no 207 Multi-Status response) or HTTPS -> HTTP redirect
     */
    fun search(search: String, callback: (at.bitfire.dav4jvm.Response, at.bitfire.dav4jvm.Response.HrefRelation) -> Unit) {
        followRedirects {
            httpClient.newCall(Request.Builder()
                    .url(location)
                    .method("SEARCH", search.toRequestBody(MIME_XML))
                    .build()).execute()
        }.use {
            processMultiStatus(it, callback)
        }
    }
    
    /**
     * Sends a PROPPATCH request to the server in order to set and remove properties.
     *
@@ -487,11 +464,14 @@ open class DavResource @JvmOverloads constructor(
     *
     * Follows up to [MAX_REDIRECTS] redirects.
     *
     * Currently expects a 207 Multi-Status response although servers are allowed to
     * return other values, too.
     *
     * @throws IOException on I/O error
     * @throws HttpException on HTTP error
     * @throws DavException on WebDAV error (like no 207 Multi-Status response) or HTTPS -> HTTP redirect
     */
    fun propPatch(
    fun proppatch(
        setProperties: Map<Property.Name, String>,
        removeProperties: List<Property.Name>,
        callback: (at.bitfire.dav4jvm.Response, at.bitfire.dav4jvm.Response.HrefRelation) -> Unit
@@ -506,6 +486,9 @@ open class DavResource @JvmOverloads constructor(
                    .build()
            ).execute()
        }.use {
            // TODO handle not only 207 Multi-Status
            // http://www.webdav.org/specs/rfc4918.html#PROPPATCH-status

            processMultiStatus(it, callback)
        }
    }
@@ -550,6 +533,29 @@ open class DavResource @JvmOverloads constructor(
        return writer.toString()
    }

    /**
     * Sends a SEARCH request (RFC 5323) with the given body to the server.
     *
     * Follows up to [MAX_REDIRECTS] redirects. Expects a 207 Multi-Status response.
     *
     * @param search    search request body (XML format, DAV:searchrequest or DAV:query-schema-discovery)
     * @param callback  called for every XML response element in the Multi-Status response
     *
     * @throws IOException on I/O error
     * @throws HttpException on HTTP error
     * @throws DavException on WebDAV error (like no 207 Multi-Status response) or HTTPS -> HTTP redirect
     */
    fun search(search: String, callback: (at.bitfire.dav4jvm.Response, at.bitfire.dav4jvm.Response.HrefRelation) -> Unit) {
        followRedirects {
            httpClient.newCall(Request.Builder()
                .url(location)
                .method("SEARCH", search.toRequestBody(MIME_XML))
                .build()).execute()
        }.use {
            processMultiStatus(it, callback)
        }
    }


    // status handling

+408 −363

File changed.

Preview size limit exceeded, changes collapsed.