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

Martin Morgan mtmorgan at fredhutch.org
Thu Aug 27 19:27:54 CEST 2015


R-devel r69197 returns appropriate errors for the cases below; I know of a few 
rough edges

- ftp error codes are not reported correctly
- download.file creates destfile before discovering that http fails, leaving an 
empty file on disk

and am happy to hear of more.

Martin

On 08/27/2015 08:46 AM, Jeroen Ooms wrote:
> On Thu, Aug 27, 2015 at 5:16 PM, Martin Maechler
> <maechler at stat.math.ethz.ch> wrote:
>> Probably I'm confused now...
>> Both R-patched and R-devel give an error (after a *long* wait!)
>> for
>>         download.file("https://someserver.com/mydata.csv", "mydata.csv")
>>
>> So that problem is I think  solved now.
>
> I'm sorry for the confusion, this was a hypothetical example.
> Connection failures are different from http status errors. Below some
> real examples of servers returning http errors. For each example the
> "internal" method correctly raises an R error, whereas the "libcurl"
> method does not.
>
> # File not found (404)
> download.file("http://httpbin.org/data.csv", "data.csv", method = "internal")
> download.file("http://httpbin.org/data.csv", "data.csv", method = "libcurl")
> readLines(url("http://httpbin.org/data.csv", method = "internal"))
> readLines(url("http://httpbin.org/data.csv", method = "libcurl"))
>
> # Unauthorized (401)
> download.file("https://httpbin.org/basic-auth/user/passwd",
> "data.csv", method = "internal")
> download.file("https://httpbin.org/basic-auth/user/passwd",
> "data.csv", method = "libcurl")
> readLines(url("https://httpbin.org/basic-auth/user/passwd", method =
> "internal"))
> readLines(url("https://httpbin.org/basic-auth/user/passwd", method = "libcurl"))
>


-- 
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793



More information about the R-devel mailing list