Skip to content
Prev 199 / 12125 Next

[R-pkg-devel] download.file and https

In random, I do the following, using R 3.2.0 or later with libcurl where
installed, and Jeroen's lightweight curl::curl otherwise.


getConnection <- function(urltxt, ...) {
    if (getRversion() >= "3.2.0" && capabilities()["libcurl"]) {
        url(urltxt, ..., method="libcurl")
    } else {
        curl(urltxt, ...)
    }
}

closeConnection <- function(con) {
    if (getRversion() >= "3.2.0" && capabilities()["libcurl"]) {
        close(con)
    } else {
        ## nothing to be done for curl()
    }
}


Hth,  Dirk