3 HttpParser <- R6::R6Class(
8 initialize = function()
12 parseJSONResponse = function(serverResponse)
14 parsed_response <- httr::content(serverResponse, as = "parsed", type = "application/json")
17 #Todo(Fudo): Test this.
18 parseWebDAVResponse = function(response, uri)
20 text <- rawToChar(response$content)
21 doc <- XML::xmlParse(text, asText=TRUE)
23 # calculate relative paths
24 base <- paste(paste("/", strsplit(uri, "/")[[1]][-1:-3], sep="", collapse=""), "/", sep="")
25 result <- XML::xpathApply(doc, "//D:response", function(node) {
27 children = XML::xmlChildren(node)
29 result$name = sub(base, "", URLdecode(XML::xmlValue(children$href)), fixed=TRUE)
30 sizeXMLNode = XML::xmlChildren(XML::xmlChildren(children$propstat)$prop)$getcontentlength
31 result$fileSize = as.numeric(XML::xmlValue(sizeXMLNode))