Rev 7747 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
url.exists =function(url, ..., .opts = list(...), curl = getCurlHandle(.opts = .opts),.header = FALSE){if(length(url) > 1) {# Really want to do this with a multi curl so asynchronous.ap = if(.header) lapply else sapplyreturn(ap(url, url.exists, curl = curl, .header = .header))}g = basicTextGatherer()failed = FALSEans = tryCatch(curlPerform(url = url, followlocation = TRUE, headerfunction = g$update,nobody = TRUE, writefunction = g$update, curl = curl),COULDNT_RESOLVE_HOST = function(x) failed <<- TRUE,error = function(x) failed <<- TRUE)if(failed)return(FALSE)if(grepl("^s?ftp", url)) {return(TRUE)} elseheader = parseHTTPHeader(g$value())if(.header)headerelseas.integer(as.integer(header["status"])/100) == 2}