Custom vcr http response object
Public fields
status
the status of the response
headers
the response headers
body
the response body
http_version
the HTTP version
opts
a list
adapter_metadata
Additional metadata used by a specific VCR adapter
disk
a boolean
Methods
Method new()
Create a new VcrResponse object
Usage
VcrResponse$new(
status,
headers,
body,
http_version,
opts,
adapter_metadata = NULL,
disk
)
Method print()
print method for the VcrResponse
class
Examples
if (FALSE) { # \dontrun{
vcr_configure(dir = tempdir())
# basic example of VcrResponse use
url <- "https://google.com"
(cli <- crul::HttpClient$new(url = url))
(res <- cli$get("get", query = list(q = "stuff")))
(x <- VcrResponse$new(res$status_http(), res$response_headers,
res$parse("UTF-8"), res$response_headers$status))
x$body
x$status
x$headers
x$http_version
x$to_hash()
x$from_hash(x$to_hash())
# check if body is compressed
url <- "https://fishbase.ropensci.org"
(cli <- crul::HttpClient$new(url = url))
(res <- cli$get("species/3"))
res$response_headers
(x <- VcrResponse$new(res$status_http(), res$response_headers,
res$parse("UTF-8"), res$response_headers$status))
x$content_encoding()
x$is_compressed()
# with disk
url <- "https://google.com"
(cli <- crul::HttpClient$new(url = url))
f <- tempfile()
(res <- cli$get("get", query = list(q = "stuff"), disk = f))
(x <- VcrResponse$new(res$status_http(), res$response_headers,
f, res$response_headers$status, disk = TRUE))
} # }