ok {crul}R Documentation

check if a url is okay

Description

check if a url is okay

Usage

ok(x, status = 200L, info = TRUE, ...)

Arguments

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 message() about it? Default: TRUE

...

args passed on to HttpClient

Details

We internally verify that status is an integer and in the known set of HTTP status codes, and that info is a boolean

Value

a single boolean, if TRUE the URL is up and okay, if FALSE it is down.

Examples

## 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)

[Package crul version 0.6.0 Index]