Skip to contents

object holds request and response objects

Details

Methods

to_hash()

Create a hash from the HTTPInteraction object

from_hash(hash)

Create a HTTPInteraction object from a hash

Public fields

request

A Request class object

response

A VcrResponse class object

recorded_at

(character) Time http interaction recorded at

Methods


Method new()

Create a new HTTPInteraction object

Usage

HTTPInteraction$new(request, response, recorded_at)

Arguments

request

A Request class object

response

A VcrResponse class object

recorded_at

(character) Time http interaction recorded at

Returns

A new HTTPInteraction object


Method to_hash()

Create a hash from the HTTPInteraction object

Usage

HTTPInteraction$to_hash()

Returns

a named list


Method from_hash()

Create a HTTPInteraction object from a hash

Usage

HTTPInteraction$from_hash(hash)

Arguments

hash

a named list

Returns

a new HttpInteraction object


Method clone()

The objects of this class are cloneable with this method.

Usage

HTTPInteraction$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

if (FALSE) { # \dontrun{
# make the request
library(vcr)
url <- "https://hb.opencpu.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)
} # }