| 1 |
\name{url.exists} |
| 2 |
\alias{url.exists} |
| 3 |
\title{Check if URL exists} |
| 4 |
\description{ |
| 5 |
This functions is analogous to \code{\link[base]{file.exists}} |
| 6 |
and determines whether a request for a specific URL responds |
| 7 |
without error. We make the request but ask the server |
| 8 |
not to return the body. We just process the header. |
| 9 |
} |
| 10 |
\usage{ |
| 11 |
url.exists(url, maxredirs = 20, ..., |
| 12 |
.opts = list(maxredirs = maxredirs, ...), |
| 13 |
curl = getCurlHandle(.opts = .opts), .header = FALSE) |
| 14 |
} |
| 15 |
\arguments{ |
| 16 |
\item{url}{a vector of one or more URLs whose existence we are to test} |
| 17 |
\item{maxredirs}{The maximal number of redirects. Set to 20 in order to fail |
| 18 |
redirect loops.} |
| 19 |
\item{\dots}{name = value pairs of Curl options.} |
| 20 |
\item{.opts}{a list of name = value pairs of Curl options.} |
| 21 |
\item{curl}{a Curl handle that the caller can specify if she wants to |
| 22 |
reuse an existing handle, e.g. with different options already |
| 23 |
specified or that has previously established a connection to the Web |
| 24 |
server} |
| 25 |
\item{.header}{a logical value that if \code{TRUE} causes the header |
| 26 |
information to be returned. |
| 27 |
} |
| 28 |
} |
| 29 |
\details{ |
| 30 |
This makes an HTTP request but with the nobody option set to |
| 31 |
\code{FALSE} so that we don't actually retrieve the contents of the URL. |
| 32 |
} |
| 33 |
\value{ |
| 34 |
If \code{.header} is \code{FALSE}, this returns |
| 35 |
\code{TRUE} or \code{FALSE} for each URL indicating whether |
| 36 |
the request was successful (had a status with a value |
| 37 |
in the 200 range). |
| 38 |
|
| 39 |
If \code{.header} is \code{TRUE}, the header is returned for the |
| 40 |
request for each URL. |
| 41 |
} |
| 42 |
\references{ |
| 43 |
HTTP specification |
| 44 |
} |
| 45 |
\author{ |
| 46 |
Duncan Temple Lang |
| 47 |
} |
| 48 |
\seealso{ |
| 49 |
\code{\link{curlPerform}} |
| 50 |
} |
| 51 |
\examples{ |
| 52 |
url.exists("https://r-project.org") |
| 53 |
try(url.exists("http://example.invalid")) |
| 54 |
} |
| 55 |
|