File: helper-crul.R

package info (click to toggle)
r-cran-crul 1.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,620 kB
  • sloc: sh: 13; makefile: 2
file content (19 lines) | stat: -rw-r--r-- 578 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# skip_on_cran()

hb <- function(x = NULL) if (is.null(x)) base_url else paste0(base_url, x)

# check various httpbin servers
urls <- c(
  "https://eu.httpbin.org", 
  "https://httpbin.org", 
  "http://httpbin.org"
)
h <- curl::new_handle(timeout = 10, failonerror = FALSE)
out <- list()
for (i in seq_along(urls)) {
  out[[i]] <- curl::curl_fetch_memory(urls[i], handle = h)
}
codes <- vapply(out, "[[", 1, "status_code")
if (!any(codes == 200)) stop("all httpbin servers down")
base_url <- urls[codes == 200][1]
cat(paste0("using base url for tests: ", base_url), sep = "\n")