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

Commit 7968c5ee authored by Ricki Hirner's avatar Ricki Hirner
Browse files

Reset status before doing further requests

parent 367b13f1
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ open class DavResource @JvmOverloads constructor(
    /** WebDAV properties of this resource */
    val properties = PropertyCollection()

    /** whether a 507 Insufficient Storage was found in the response */
    /** whether a 507 Insufficient Storage was found in the previous response */
    var furtherResults = false

    /** members of this resource */
@@ -83,6 +83,7 @@ open class DavResource @JvmOverloads constructor(
     */
    @Throws(IOException::class, HttpException::class, DavException::class)
    fun options() {
        resetResponse()
        capabilities.clear()

        val response = httpClient.newCall(Request.Builder()
@@ -103,6 +104,8 @@ open class DavResource @JvmOverloads constructor(
     */
    @Throws(IOException::class, HttpException::class)
    fun mkCol(xmlBody: String?) {
        resetResponse()

        val rqBody = if (xmlBody != null) RequestBody.create(MIME_XML, xmlBody) else null

        var response: Response? = null
@@ -130,6 +133,8 @@ open class DavResource @JvmOverloads constructor(
     */
    @Throws(IOException::class, HttpException::class, DavException::class)
    fun get(accept: String): ResponseBody {
        resetResponse()

        var response: Response? = null
        for (attempt in 1..MAX_REDIRECTS) {
            response = httpClient.newCall(Request.Builder()
@@ -171,6 +176,8 @@ open class DavResource @JvmOverloads constructor(
     */
    @Throws(IOException::class, HttpException::class)
    fun put(body: RequestBody, ifMatchETag: String?, ifNoneMatch: Boolean): Boolean {
        resetResponse()

        var redirected = false
        var response: Response? = null
        for (attempt in 1..MAX_REDIRECTS) {
@@ -211,6 +218,8 @@ open class DavResource @JvmOverloads constructor(
     */
    @Throws(IOException::class, HttpException::class)
    fun delete(ifMatchETag: String?) {
        resetResponse()

        var response: Response? = null
        for (attempt in 1..MAX_REDIRECTS) {
            val builder = Request.Builder()
@@ -248,6 +257,8 @@ open class DavResource @JvmOverloads constructor(
     */
    @Throws(IOException::class, HttpException::class, DavException::class)
    fun propfind(depth: Int, vararg reqProp: Property.Name) {
        resetResponse()

        // build XML request body
        val serializer = XmlUtils.newSerializer()
        val writer = StringWriter()
@@ -567,7 +578,8 @@ open class DavResource @JvmOverloads constructor(
            }

            // set properties for target
            target.furtherResults = insufficientStorage
            if (insufficientStorage)
                target.furtherResults = true
            target.properties.merge(properties, true)
        }

@@ -590,6 +602,7 @@ open class DavResource @JvmOverloads constructor(
            }
        }

        resetResponse()
        try {
            parser.setInput(reader)

@@ -660,4 +673,8 @@ open class DavResource @JvmOverloads constructor(
        related.clear()
    }

    protected fun resetResponse() {
        furtherResults = false
    }

}