R/check_connection.R

Defines functions check_connection

#' @keywords internal
#' @noRd
check_connection <- function(url_to_check) {
  internet_check <- tryCatch(
    {
      url_con <- base::url(
        description = url_to_check,
        open = "rb"
      )
      base::readLines(url_con, n = 1)
      base::close(url_con)
      TRUE
    },
    error = function(e) {
      FALSE
    }
  )
  return(internet_check)
}

Try the condathis package in your browser

Any scripts or data that you put into this service are public.

condathis documentation built on April 12, 2025, 2:01 a.m.