Skip to content
Snippets Groups Projects

Rcode

Merged Marek Ostaszewski requested to merge Rcode into master
2 files
+ 13
5
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 13
1
@@ -27,7 +27,19 @@ ask_GET <- function(api_call, token = NULL, ctype = NULL,
httr::set_cookies(MINERVA_AUTH_TOKEN = token),
httr::config(verbose = verbose))
if(httr::status_code(resp) == 200) {
return(httr::content(resp, as = "text", encoding = encoding))
### when the content is sent as a zip file, it needs to be handled differently,
### i.e. saved to a tmp file and unzipped
if(httr::headers(resp)$`content-type` == "application/zip") {
tmp <- tempfile()
tmpc <- file(tmp, "wb")
writeBin(httr::content(resp, as = "raw"), con = tmpc)
close(tmpc)
unzipped <- utils::unzip(tmp)
file.remove(tmp)
return(unzipped)
} else {
return(httr::content(resp, as = "text", encoding = encoding))
}
} else {
warning("minervar:ask_GET(): API call error:")
warning(resp)
Loading