vcr (version 1.2.2)

Request: The request of an HTTPInteraction

Description

object that handled all aspects of a request

Arguments

Public fields

method

(character) http method

uri

(character) a uri

scheme

(character) scheme (http or https)

host

(character) host (e.g., stuff.org)

path

(character) path (e.g., foo/bar)

query

(character) query params, named list

body

(character) named list

headers

(character) named list

skip_port_stripping

(logical) whether to strip thhe port

hash

(character) a named list - internal use

opts

(character) options - internal use

disk

(logical) xx

fields

(various) request body details

output

(various) request output details, disk, memory, etc

Methods


Method new()

Create a new Request object

Usage

Request$new(method, uri, body, headers, opts, disk, fields, output)

Arguments

method

(character) the HTTP method (i.e. head, options, get, post, put, patch or delete)

uri

(character) request URI

body

(character) request body

headers

(named list) request headers

opts

(named list) options internal use

disk

(boolean), is body a file on disk

fields

(various) post fields

output

(various) output details

Returns

A new Request object


Method to_hash()

Convert the request to a list

Usage

Request$to_hash()

Returns

list


Method from_hash()

Convert the request to a list

Usage

Request$from_hash(hash)

Arguments

hash

a list

Returns

a new Request object


Method clone()

The objects of this class are cloneable with this method.

Usage

Request$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

Run this code
url <- "https://eu.httpbin.org/post"
body <- list(foo = "bar")
headers <- list(
  `User-Agent` = "libcurl/7.54.0 r-curl/3.2 crul/0.5.2",
  `Accept-Encoding` = "gzip, deflate",
  Accept = "application/json, text/xml, application/xml, */*"
)

(x <- Request$new("POST", url, body, headers))
x$body
x$method
x$uri
x$host
x$path
x$headers
h <- x$to_hash()
x$from_hash(h)

Run the code above in your browser using DataLab