R/handle-url.r

Defines functions handle_url

handle_url <- function(handle = NULL, url = NULL, ...) {
  if (is.null(url) && is.null(handle)) {
    stop("Must specify at least one of url or handle")
  }

  if (is.null(handle)) handle <- handle_find(url)
  if (is.null(url)) url <- handle$url

  # If named components in ..., modify the url
  new <- named(list(...))
  if (length(new) > 0 || is.url(url)) {
    old <- parse_url(url)
    url <- build_url(utils::modifyList(old, new))
  }

  list(handle = handle, url = url)
}
r-lib/httr documentation built on Nov. 5, 2023, 7:26 a.m.