| curlGetHeaders | R Documentation |
Retrieve the headers for a URL for a supported protocol such ashttp://,ftp://,https:// andftps://.An optional function not supported on all platforms.
curlGetHeaders(url, redirect = TRUE, verify = TRUE, timeout = 0L, TLS = "")
url | character string specifying the URL. |
redirect | logical: should redirections be followed? |
verify | logical: should certificates be verified as validand applying to that host? |
timeout | integer: the maximum time in seconds the request isallowed to take. Non-positive and invalid values are ignored(including the default). (Added inR 4.1.0.) |
TLS | character: the minimum version of the TLS protocol to be usedfor |
This reports whatcurl -I -L orcurl -I wouldreport. For aftp:// URL the ‘headers’ are a record ofthe conversation between client and server before data transfer.
Only 500 header lines will be reported: there is a limit of 20redirections so this should suffice (and even 20 would indicateproblems).
If argumenttimeout is not set to a positive integer this usesgetOption("timeout") which defaults to 60 seconds. Asthe request cannot be interrupted you may want to consider a shortervalue.
To see all the details of the interaction with the server(s) setoptions(internet.info = 1).
HTTP[S] servers are allowed to refuse requests to read the headers andsome do: this will result in astatus of405.
For possible issues with secure URLs (especially on Windows) seedownload.file.
There is a security risk in not verifying certificates, but as onlythe headers are captured it is slight. Usually looking at the URL ina browser will reveal what the problem is (and it may well bemachine-specific).
A character vector with integer attribute"status" (thelast-received ‘status’ code). If redirection occurs this will includethe headers for all the URLs visited.
For the interpretation of ‘status’ codes seehttps://en.wikipedia.org/wiki/List_of_HTTP_status_codes andhttps://en.wikipedia.org/wiki/List_of_FTP_server_return_codes.A successful FTP connection will usually have status 250, 257 or 350.
capabilities("libcurl") to see if this is supported.libcurlVersion for the version oflibcurl in use.
optionsHTTPUserAgent andtimeout are used.
## needs Internet access, results varycurlGetHeaders("http://bugs.r-project.org") ## this redirects to https://curlGetHeaders("https://httpbin.org/status/404") ## returns statuscurlGetHeaders("ftp://cran.r-project.org")Add the following code to your website.
For more information on customizing the embed code, readEmbedding Snippets.