Learn R Programming

crul (version 0.3.0)

AsyncVaried: Async client for different request types

Description

Async client for different request types

Arguments

..., .list
Any number of objects of class HttpRequest, must supply inputs to one of these parameters, but not both

Value

An object of class AsyncVaried with variables and methods

Details

Methods
request()
execute asynchronous requests
requests()
list requests
parse(encoding = "UTF-8")
parse content
status_code()
(integer) HTTP status codes
status()
(list) HTTP status objects
content()
raw content
times()
curl request times

See Also

Other async: Async

Examples

Run this code
## Not run: ------------------------------------
# # pass in requests via ...
# req1 <- HttpRequest$new(
#   url = "https://httpbin.org/get",
#   opts = list(verbose = TRUE),
#   headers = list(foo = "bar")
# )$get()
# req2 <- HttpRequest$new(url = "https://httpbin.org/post")$post()
# out <- AsyncVaried$new(req1, req2)
# out$request()
# out$status()
# out$status_code()
# out$content()
# out$times()
# out$parse()
# out$responses()
# 
# # pass in requests in a list via .list param
# reqlist <- list(
#   HttpRequest$new(url = "https://httpbin.org/get")$get(),
#   HttpRequest$new(url = "https://httpbin.org/post")$post(),
#   HttpRequest$new(url = "https://httpbin.org/put")$put(),
#   HttpRequest$new(url = "https://httpbin.org/delete")$delete(),
#   HttpRequest$new(url = "https://httpbin.org/get?g=5")$get(),
#   HttpRequest$new(
#     url = "https://httpbin.org/post")$post(body = list(y = 9)),
#   HttpRequest$new(
#     url = "https://httpbin.org/get")$get(query = list(hello = "world"))
# )
# 
# out <- AsyncVaried$new(.list = reqlist)
# out$request()
# out$status()
# out$status_code()
# out$content()
# out$times()
# out$parse()
## ---------------------------------------------

Run the code above in your browser using DataLab