| ok {crul} | R Documentation |
check if a url is okay
ok(x, status = 200L, info = TRUE, ...)
x |
either a URL as a character string, or an object of class HttpClient |
status |
(integer) an HTTP status code, must be an integer. By default this is 200L, since this is the most common signal that a URL is okay, but there may be cases in which your URL is okay if it's a 201L, or some other status code. |
info |
(logical) in the case of an error, do you want a
|
... |
args passed on to HttpClient |
We internally verify that status is an integer and in the known set of HTTP status codes, and that info is a boolean
a single boolean, if TRUE the URL is up and okay,
if FALSE it is down.
## Not run:
# 200
ok("https://google.com")
# 200
ok("https://httpbin.org/status/200")
# 404
ok("https://httpbin.org/status/404")
# doesn't exist
ok("https://stuff.bar")
# doesn't exist
ok("stuff")
# with HttpClient
z <- crul::HttpClient$new("https://httpbin.org/status/404",
opts = list(verbose = TRUE))
ok(z)
## End(Not run)