Movatterモバイル変換


[0]ホーム

URL:


rdrr.io

curlGetHeaders: Retrieve Headers from URLs

curlGetHeadersR Documentation

Retrieve Headers from URLs

Description

Retrieve the headers for a URL for a supported protocol such ashttp://,ftp://,https:// andftps://.An optional function not supported on all platforms.

Usage

curlGetHeaders(url, redirect = TRUE, verify = TRUE,               timeout = 0L, TLS = "")

Arguments

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 usedforhttps:// URLs: the default ("") is no restrictionbeyond that of the underlyinglibcurl (usually 1.0). Othervalid values are"1.1","1.2" (both forlibcurl7.34.0 and later) and"1.3" (7.52.0 and later), if supportedby the underlying version oflibcurl and the SSL library it uses.

Details

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).

Value

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.

See Also

capabilities("libcurl") to see if this is supported.libcurlVersion for the version oflibcurl in use.

optionsHTTPUserAgent andtimeout are used.

Examples

## 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")

What can we improve?

R Package Documentation

Browse R Packages

We want your feedback!

Note that we can't provide technical support on individual packages. You should contact the package authors for that.

 
Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, readEmbedding Snippets.

Close

[8]ページ先頭

©2009-2025 Movatter.jp