is_http_success | R Documentation |
Convenience wrapper around a bunch of httr2 functions that returns
TRUE
if the specified url
could be resolved and a HEAD
request could
be successfully completed, or
FALSE
in any other case.
is_http_success(
url,
max_tries = 1L,
retry_on_failure = FALSE,
is_transient = NULL,
verbosity = NULL
)
url |
HTTP protocol address. The scheme is optional, so both |
max_tries |
Maximum number of request attempts in case of an HTTP error. An integerish scalar. Retries are performed using exponential backoff and jitter, see |
retry_on_failure |
Treat low-level failures as if they are transient errors that can be retried. |
is_transient |
A predicate function that takes a single argument
(the response) and returns |
verbosity |
How much information to print? This is a wrapper
around
Use |
This function is similar to RCurl::url.exists()
, i.e. it only retrieves the header, no body, but is based on httr2 which in turn is
based on curl.
For checks on lower levels of the network stack like performing DNS queries or TCP port pings, see the pingr package.
A logical scalar.
Other HTTP functions:
is_url()
,
req_cached()
pal::is_http_success("goo.gl")
pal::is_http_success("https://google.com/")
pal::is_http_success("https://google.not/")
# by default, requests are only retried on HTTP 429 and 503 status codes
pal::is_http_success(url = "https://httpstat.us/503",
max_tries = 2,
verbosity = 1)
pal::is_http_success(url = "https://httpstat.us/500",
max_tries = 2,
verbosity = 1)
# to retry on *all* failing status codes, set `is_transient` accordingly:
pal::is_http_success(url = "https://httpstat.us/500",
max_tries = 2,
is_transient = \(x) TRUE,
verbosity = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.