JitPack-only publishing conflicts with FAIL_ON_PROJECT_REPOS, artifacts are unsigned and not immutable, and upstream shipped two breaking majors 19 days apart. 2.2.1 is the last OkHttp release: 3.0.0 moved to Ktor and 4.x needs Java 21, and SYNC.md's whole auth section is written in OkHttp terms, so 4.x would have invalidated it. A plain JVM module, not an Android library — the tree has no Android imports and keeping it that way keeps the floret-kit extraction a file move. Four changes from upstream, all in dav/PROVENANCE.md: - commons-lang3 dropped (one import, one call). The replacement requires the whole string to be consumed, as DateUtils did: pattern 1 ends in a literal 'GMT', so SimpleDateFormat would match "...GMT+02:00" as a prefix and throw the offset away. - HTTP dates were parsed and formatted in the device's local zone — the GMT in the format string is a quoted literal and timeZone was never set, so every getlastmodified was out by the local UTC offset. Upstream tests dates nowhere. The formatter is also no longer shared and mutable. - dav4jvm#209: permanent redirects now reach the caller via DavResource.permanentLocation, cleared per request so it never describes an earlier one. - xpp3 is compileOnly; Android supplies org.xmlpull.v1. SYNC.md's other claimed defect, "does not follow 303", is not true of 2.2.1 — pinned by a test rather than removed from the notes. CI names :dav:test explicitly; testDebugUnitTest is Android-only and would have run none of the vendored suite. lintDebug added to the per-chunk checks after it caught a literal byte-order mark left by chunk 1.
69 lines
2.2 KiB
Kotlin
69 lines
2.2 KiB
Kotlin
/*
|
|
* Copyright © Ricki Hirner (bitfire web engineering).
|
|
* All rights reserved. This program and the accompanying materials
|
|
* are made available under the terms of the GNU Public License v3.0
|
|
* which accompanies this distribution, and is available at
|
|
* http://www.gnu.org/licenses/gpl.html
|
|
*/
|
|
|
|
package at.bitfire.dav4jvm
|
|
|
|
import at.bitfire.dav4jvm.Response.Companion.STATUS
|
|
import at.bitfire.dav4jvm.XmlUtils.propertyName
|
|
import okhttp3.Protocol
|
|
import okhttp3.internal.http.StatusLine
|
|
import org.xmlpull.v1.XmlPullParser
|
|
import java.net.ProtocolException
|
|
import java.util.*
|
|
|
|
/**
|
|
* Represents a WebDAV propstat XML element.
|
|
*
|
|
* <!ELEMENT propstat (prop, status, error?, responsedescription?) >
|
|
*/
|
|
data class PropStat(
|
|
val properties: List<Property>,
|
|
val status: StatusLine,
|
|
val error: List<Error>? = null
|
|
) {
|
|
|
|
companion object {
|
|
|
|
@JvmField
|
|
val NAME = Property.Name(XmlUtils.NS_WEBDAV, "propstat")
|
|
|
|
private val ASSUMING_OK = StatusLine(Protocol.HTTP_1_1, 200, "Assuming OK")
|
|
private val INVALID_STATUS = StatusLine(Protocol.HTTP_1_1, 500, "Invalid status line")
|
|
|
|
fun parse(parser: XmlPullParser): PropStat {
|
|
val depth = parser.depth
|
|
|
|
var status: StatusLine? = null
|
|
val prop = LinkedList<Property>()
|
|
|
|
var eventType = parser.eventType
|
|
while (!(eventType == XmlPullParser.END_TAG && parser.depth == depth)) {
|
|
if (eventType == XmlPullParser.START_TAG && parser.depth == depth + 1)
|
|
when (parser.propertyName()) {
|
|
DavResource.PROP ->
|
|
prop.addAll(Property.parse(parser))
|
|
STATUS ->
|
|
status = try {
|
|
StatusLine.parse(parser.nextText())
|
|
} catch (e: ProtocolException) {
|
|
// invalid status line, treat as 500 Internal Server Error
|
|
INVALID_STATUS
|
|
}
|
|
}
|
|
eventType = parser.next()
|
|
}
|
|
|
|
return PropStat(prop, status ?: ASSUMING_OK)
|
|
}
|
|
|
|
}
|
|
|
|
|
|
fun isSuccess() = status.code/100 == 2
|
|
|
|
} |