-
Notifications
You must be signed in to change notification settings - Fork 86
/
Copy pathlibcurl.R
42 lines (31 loc) · 1.27 KB
/
libcurl.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
## These are tests that require libcurl functionality (available
## everywhere as from R 4.2.0) and a working Internet connection.
## Nowadays method = "libcurl" is the default everywhere for http[s]://
## This used to check that https:// worked and skip if not, but then
## all the tests redirected to https://
## check basic Internet access
if(.Platform$OS.type == "unix" &&
is.null(nsl("cran.r-project.org"))) q()
tf <- tempfile()
download.file("https://cran.r-project.org/", tf)
file.size(tf)
unlink(tf)
## test url connections on http -- this now redirects to https://
str(readLines(zz <- url("http://cran.r-project.org/")))
zz
stopifnot(identical(summary(zz)$class, "url-libcurl"))
close(zz)
## and check that direct https:// works
str(readLines(zz <- url("https://cran.r-project.org/")))
close(zz)
## via read.table (which closes the connection) -- this now redirects to https://
tail(read.table(url("http://www.stats.ox.ac.uk/pub/datasets/csb/ch11b.dat")))
## check option works
options(url.method = "libcurl")
zz <- url("http://www.stats.ox.ac.uk/pub/datasets/csb/ch11b.dat")
stopifnot(identical(summary(zz)$class, "url-libcurl"))
close(zz)
curlGetHeaders("https://developer.r-project.org")
example(curlGetHeaders, run.donttest = TRUE)
showConnections(all = TRUE)
proc.time()