Learn R Programming

vcr (version 1.6.0)

RequestHandlerHttr: RequestHandlerHttr

Description

Methods for the httr package, building on RequestHandler

Arguments

Super class

vcr::RequestHandler -> RequestHandlerHttr

Methods

Inherited methods


Method new()

Create a new RequestHandlerHttr object

Usage

RequestHandlerHttr$new(request)

Arguments

request

The request from an object of class HttpInteraction

Returns

A new RequestHandlerHttr object


Method clone()

The objects of this class are cloneable with this method.

Usage

RequestHandlerHttr$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

Run this code
if (FALSE) {
vcr_configure(
 dir = tempdir(),
 record = "once"
)

# GET request
library(httr)
load("~/httr_req.rda")
req
x <- RequestHandlerHttr$new(req)
# x$handle()

# POST request
library(httr)
webmockr::httr_mock()
mydir <- file.path(tempdir(), "testing_httr")
invisible(vcr_configure(dir = mydir))
use_cassette(name = "testing2", {
  res <- POST("https://hb.opencpu.org/post", body = list(foo = "bar"))
}, match_requests_on = c("method", "uri", "body"))

load("~/httr_req_post.rda")
insert_cassette("testing3")
httr_req_post
x <- RequestHandlerHttr$new(httr_req_post)
x
# x$handle()
self=x

}

Run the code above in your browser using DataLab