Learn R Programming

crul (version 0.5.0)

Async: Simple async client

Description

A client to work with many URLs, but all with the same HTTP method

Arguments

urls

(character) one or more URLs (required)

Value

a list, with objects of class HttpResponse(). Responses are returned in the order they are passed in.

Details

Methods

get(path, query, disk, stream, ...)

make async GET requests for all URLs

post(path, query, body, encode, disk, stream, ...)

make async POST requests for all URLs

put(path, query, body, encode, disk, stream, ...)

make async PUT requests for all URLs

patch(path, query, body, encode, disk, stream, ...)

make async PATCH requests for all URLs

delete(path, query, body, encode, disk, stream, ...)

make async DELETE requests for all URLs

head(path, ...)

make async HEAD requests for all URLs

See HttpClient() for information on parameters.

See Also

Other async: AsyncVaried

Examples

Run this code
# NOT RUN {
cc <- Async$new(
  urls = c(
    'https://httpbin.org/',
    'https://httpbin.org/get?a=5',
    'https://httpbin.org/get?foo=bar'
  )
)
cc
(res <- cc$get())
res[[1]]
res[[1]]$url
res[[1]]$success()
res[[1]]$status_http()
res[[1]]$response_headers
res[[1]]$method
res[[1]]$content
res[[1]]$parse("UTF-8")

lapply(res, function(z) z$parse("UTF-8"))
# }

Run the code above in your browser using DataLab