Learn R Programming

vcr (version 1.6.0)

vcr-package: vcr: Record 'HTTP' Calls to Disk

Description

Record test suite 'HTTP' requests and replays them during future runs. A port of the Ruby gem of the same name (https://github.com/vcr/vcr/). Works by hooking into the 'webmockr' R package for matching 'HTTP' requests by various rules ('HTTP' method, 'URL', query parameters, headers, body, etc.), and then caching real 'HTTP' responses on disk in 'cassettes'. Subsequent 'HTTP' requests matching any previous requests in the same 'cassette' use a cached 'HTTP' response.

Arguments

Backstory

A Ruby gem of the same name (VCR, https://github.com/vcr/vcr) was created many years ago and is the original. Ports in many languages have been done. Check out that GitHub repo for all the details on how the canonical version works.

Main functions

The use_cassette function is most likely what you'll want to use. It sets the cassette you want to record to, inserts the cassette, and then ejects the cassette, recording the interactions to the cassette.

Instead, you can use insert_cassette, but then you have to make sure to use eject_cassette.

vcr configuration

vcr_configure is the function to use to set R session wide settings. See it's manual file for help.

Record modes

See recording for help on record modes.

Request matching

See request-matching for help on the many request matching options.

Async

As of crul v1.5, vcr will work for async http requests with crul. httr does not do async requests, and httr2 async plumbing does not have any hooks for mocking via webmockr or recording real requests via this package

Author

Maintainer: Scott Chamberlain sckott@protonmail.com (ORCID)

Authors:

Other contributors:

  • rOpenSci (https://ropensci.org) [funder]

See Also