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

Commit 2a213b46 authored by Ricki Hirner's avatar Ricki Hirner
Browse files

GetContentType: use okhttp MediaType

parent c813b0b2
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -10,10 +10,11 @@ import at.bitfire.dav4jvm.Property
import at.bitfire.dav4jvm.PropertyFactory
import at.bitfire.dav4jvm.XmlUtils
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import org.xmlpull.v1.XmlPullParser

data class GetContentType(
        val type: String?
        val type: MediaType?
): Property {

    companion object {
@@ -21,8 +22,6 @@ data class GetContentType(
        val NAME = Property.Name(XmlUtils.NS_WEBDAV, "getcontenttype")
    }

    constructor(mediaType: MediaType): this(mediaType.toString())


    object Factory: PropertyFactory {

@@ -30,7 +29,8 @@ data class GetContentType(

        override fun create(parser: XmlPullParser) =
                // <!ELEMENT getcontenttype (#PCDATA) >
                GetContentType(XmlUtils.readText(parser))
                GetContentType(XmlUtils.readText(parser)?.toMediaTypeOrNull())

    }

}
+1 −1
Original line number Diff line number Diff line
@@ -219,7 +219,7 @@ class DavResourceTest {
            assertEquals(sampleText, response.body!!.string())

            assertEquals("My Weak ETag", GetETag.fromResponse(response)?.eTag)
            assertEquals("application/x-test-result", GetContentType(response.body!!.contentType()!!).type)
            assertEquals("application/x-test-result".toMediaType(), GetContentType(response.body!!.contentType()!!).type)
        }
        assertTrue(called)