async (version 0.0.0.9004)

http_head: Asynchronous HTTP HEAD request

Description

Asynchronous HTTP HEAD request

Usage

http_head(url, headers = character(), file = NULL,
  options = list(timeout = 600), on_progress = NULL)

Arguments

url

URL to connect to.

headers

HTTP headers to send.

file

If not NULL, it must be a string, specifying a file. The body of the response is written to this file.

options

Options to set on the handle. Passed to curl::handle_setopt().

on_progress

Progress handler function. It is only used if the response body is written to a file. See details below.

Value

Deferred object.

See Also

Other asyncronous HTTP calls: http_get

Examples

Run this code
# NOT RUN {
afun <- async(function() {
  dx <- http_head("https://eu.httpbin.org/status/200")$
    then(function(x) x$status_code)
})
synchronise(afun())

# Check a list of URLs in parallel
afun <- function(urls) {
  when_all(.list = lapply(urls, http_head))$
    then(function(x) lapply(x, "[[", "status_code"))
}
urls <- c("https://google.com", "https://eu.httpbin.org")
synchronise(afun(urls))
# }

Run the code above in your browser using DataCamp Workspace