Skip to content
Prev 50918 / 63424 Next

Issues with libcurl + HTTP status codes (eg. 403, 404)

Thanks for looking into this so promptly!

Should users expect the behaviour to be congruent across all of the
supported external programs (curl, wget) as well? E.g.

    URL <- "http://cran.rstudio.org/no/such/file/here.tar.gz"
    download <- function(file, method, ...)
      print(download.file(file, destfile = tempfile(), method = method, ...))

    download(URL, method = "internal") ## error
    download(URL, method = "curl") ## status code 0
    download(URL, method = "wget") ## warning (status code 8)
    download(URL, method = "libcurl") ## status code 0

It seems unfortunate that the behaviour differs across each method; at
least in my mind `download.file()` should be a unified interface that
tries to do the 'same thing' regardless of the chosen method.

FWIW, one can force 'curl' to fail on HTTP error codes (-f) and this
can be passed down by R, e.g.

    download(URL, method = "curl", extra = "-f") ## warning (status code 22)

but I still think this should be promoted to an error rather than a
warning. (Of course, changing that would imply a backwards
incompatible change; however, I think it would be the correct change).

(PS: I just tested r69197 and method = "libcurl" does indeed report an
error now in the above test case on my system [OS X]; thanks!)

Kevin
On Thu, Aug 27, 2015 at 10:27 AM, Martin Morgan <mtmorgan at fredhutch.org> wrote: