Skip to contents

Check httr response code and cache locally results

Usage

cas_check_response(
  url = NULL,
  followlocation = TRUE,
  url_encode = TRUE,
  wait = 1,
  output_only_newly_checked = FALSE,
  output_only_cached = FALSE,
  cache_invalidate = NULL,
  index = FALSE,
  index_group = NULL,
  db_connection = NULL,
  disconnect_db = FALSE,
  check_db = TRUE,
  write_db = TRUE,
  ...
)

Arguments

url

A character vector of urls, or a data frame with a url column, typically retrieved with cas_get_urls_df().

followlocation

Logical, defaults to TRUE, passed to httr2::req_options(). If TRUE, follows all redirects and reports data about the final response url is reached. If FALSE, it reports the status message of the original server even if a redirect was set; the code of the original redirect is reported, and the destination of the redirect is returned in the response_url column. Data with and without followlocation enabled are stored in separate databases.

url_encode

Logical, defaults to TRUE. If TRUE, it parses the urls with URLencode(repeated=FALSE) in order to process correctly URLs including e.g. spaces or other special characters.

wait

Defaults to 1. Number of seconds to wait between downloading one page and the next. Can be increased to reduce server load, or can be set to 0 when this is not an issue.

output_only_cached

Defaults to FALSE. If TRUE, only previously cached responses are kept.

cache_invalidate

Defaults to NULL. If given, it can be either a date or date time object, or a character vector than can be coerced with as.POSIXct(); only responses cached since that date will be kept. If numeric, it is understood as number of days: only cached responses more recent than the given number of days will be kept.

check_db

Defaults to TRUE. If TRUE, checks if given URL has already been checked in local database, and queries APIs only for URLs that have not been previously checked.

write_db

Defaults to TRUE. If TRUE, writes result to a local database.

...

Passed to cas_get_db_file().

Value

A data frame with response status for each given url.

Examples

if (FALSE) { # \dontrun{
cas_check_response("https://example.com")
} # }