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

Winston Chang winstonchang1 at gmail.com
Fri Jul 3 17:07:11 CEST 2015


My downloader package was created to deal with https on various platforms:
  http://cran.r-project.org/web/packages/downloader/index.html

The package dates back to before R had libcurl support. It's very
simple: if you're on Windows, it uses setInternet2(), which enable
https support, and if you're on non-Windows, it looks for wget, curl,
and then lynx.

You don't have to import downloader in order to do this - there's just
one function you'd need, which, as far as I'm concerned, you can put
in your code:
  https://github.com/wch/downloader/blob/master/R/download.r

If you need the code to officially relicensed, feel free to contact me by email.

-Winston




On Fri, Jul 3, 2015 at 9:24 AM, Paul Gilbert <pgilbert902 at gmail.com> wrote:
> The difficulty with most workarounds suggested so far is the expanded list
> of dependencies. My package and quantmod, have had a simple dependency on
> download.file in utils. Picking on Dirks suggestion as an example, it would
> add a system dependency on libcurl and an R package dependency on curl,
> which in turn has system dependencies libcurl-devel (rpm) or
> libcurl4-openssl-dev (deb). Furthermore, it suggests testthat, knitr,
> jsonlite, rmarkdown, and magrittr, which means that these and their
> dependencies, imports, and suggests all need to be installed and working in
> order for me to test, and working with R-devel for me to submit to CRAN.
>
> Let me mention again that this problem is not specific to my package or
> quantmod. It will be quickly affecting everyone that downloads from US
> government websites, not to mention that other governments and commercial
> web sites may start doing the same thing.
>
> Paul
>
> On 07/03/2015 06:39 AM, Dirk Eddelbuettel wrote:
>>
>>
>> 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
>>
>
> ______________________________________________
> R-package-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel



More information about the R-package-devel mailing list