RequestHandlerHttr2 | R Documentation |
Methods for the httr2 package, building on RequestHandler
vcr::RequestHandler
-> RequestHandlerHttr2
new()
Create a new RequestHandlerHttr2
object
RequestHandlerHttr2$new(request)
request
The request from an object of class HttpInteraction
A new RequestHandlerHttr2
object
clone()
The objects of this class are cloneable with this method.
RequestHandlerHttr2$clone(deep = FALSE)
deep
Whether to make a deep clone.
## Not run:
# GET request
library(httr2)
req <- request("https://hb.opencpu.org/post") %>%
req_body_json(list(foo = "bar"))
x <- RequestHandlerHttr2$new(req)
# x$handle()
# POST request
library(httr2)
mydir <- file.path(tempdir(), "testing_httr2")
invisible(vcr_configure(dir = mydir))
req <- request("https://hb.opencpu.org/post") %>%
req_body_json(list(foo = "bar"))
use_cassette(name = "testing3", {
response <- req_perform(req)
}, match_requests_on = c("method", "uri", "body"))
use_cassette(name = "testing3", {
response2 <- req_perform(req)
}, match_requests_on = c("method", "uri", "body"))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.