}
}
+fun <T, C : XmlTagConsumer<T>> C.webDavPropPatchResult(path: StoragePath, webRoot: String) = declaration()
+ .root("multistatus", namespace = "DAV:") {
+ "response" {
+ "href" { +"${webRoot.removeSuffix("/")}/$path".removeSuffix("/") }
+ "propstat" {
+ "status" { +"HTTP/1.1 200 OK" }
+ }
+ }
+ }
+
suspend fun FileStorage.copyWebDav(source: StoragePath, target: StoragePath): Boolean {
return when (getType(source)) {
StoredFileType.DIRECTORY -> createDir(target) && (listDir(source)
}
}
+suspend fun ApplicationCall.webDavPropPatch(path: StoragePath) {
+ beforeWebDav()
+
+ val exists = FileStorage.instance.getType(path) != null
+ if (exists)
+ respondXml(status = HttpStatusCode.MultiStatus) {
+ webDavPropPatchResult(path, WebDavDomainName)
+ }
+ else
+ respond(HttpStatusCode.NotFound)
+}
+
suspend fun ApplicationCall.webDavGet(path: StoragePath) {
beforeWebDav()
route("{path...}") {
method(HttpMethod.parse("OPTIONS")) { handle { call.webDavOptions() } }
method(HttpMethod.parse("PROPFIND")) { handle { call.webDavPropFind(call.webDavPath) } }
+ method(HttpMethod.parse("PROPPATCH")) { handle { call.webDavPropPatch(call.webDavPath) } }
method(HttpMethod.parse("GET")) { handle { call.webDavGet(call.webDavPath) } }
method(HttpMethod.parse("MKCOL")) { handle { call.webDavMkCol(call.webDavPath) } }
method(HttpMethod.parse("PUT")) { handle { call.webDavPut(call.webDavPath) } }