HTTPInteraction | R Documentation |
object holds request and response objects
Methods
to_hash()
Create a hash from the HTTPInteraction object
from_hash(hash)
Create a HTTPInteraction object from a hash
request
A Request
class object
response
A VcrResponse
class object
recorded_at
(character) Time http interaction recorded at
new()
Create a new HTTPInteraction
object
HTTPInteraction$new(request, response, recorded_at)
request
A Request
class object
response
A VcrResponse
class object
recorded_at
(character) Time http interaction recorded at
A new HTTPInteraction
object
to_hash()
Create a hash from the HTTPInteraction object
HTTPInteraction$to_hash()
a named list
from_hash()
Create a HTTPInteraction object from a hash
HTTPInteraction$from_hash(hash)
hash
a named list
a new HttpInteraction
object
clone()
The objects of this class are cloneable with this method.
HTTPInteraction$clone(deep = FALSE)
deep
Whether to make a deep clone.
## Not run:
# make the request
library(vcr)
url <- "https://eu.httpbin.org/post"
body <- list(foo = "bar")
cli <- crul::HttpClient$new(url = url)
res <- cli$post(body = body)
# build a Request object
(request <- Request$new("POST", uri = url,
body = body, headers = res$response_headers))
# build a VcrResponse object
(response <- VcrResponse$new(
res$status_http(),
res$response_headers,
res$parse("UTF-8"),
res$response_headers$status))
# make HTTPInteraction object
(x <- HTTPInteraction$new(request = request, response = response))
x$recorded_at
x$to_hash()
# make an HTTPInteraction from a hash with the object already made
x$from_hash(x$to_hash())
# Make an HTTPInteraction from a hash alone
my_hash <- x$to_hash()
HTTPInteraction$new()$from_hash(my_hash)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.