Learn R Programming

webmockr (version 2.0.0)

RequestSignature: RequestSignature

Description

General purpose request signature builder

Arguments

Public fields

method

(character) an http method

uri

(character) a uri

body

(various) request body

headers

(list) named list of headers

proxies

(list) proxies as a named list

auth

(list) authentication details, as a named list

url

internal use

disk

(character) if writing to disk, the path

fields

(various) request body details

output

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

Methods


Method new()

Create a new RequestSignature object

Usage

RequestSignature$new(method, uri, options = list())

Arguments

method

the HTTP method (any, head, options, get, post, put, patch, trace, or delete). "any" matches any HTTP method. required.

uri

(character) request URI. required.

options

(list) options. optional. See Details.

Returns

A new RequestSignature object


Method print()

print method for the RequestSignature class

Usage

RequestSignature$print()

Arguments

x

self

...

ignored


Method to_s()

Request signature to a string

Usage

RequestSignature$to_s()

Returns

a character string representation of the request signature


Method clone()

The objects of this class are cloneable with this method.

Usage

RequestSignature$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

Run this code
# make request signature
x <- RequestSignature$new(method = "get", uri = "https:/httpbin.org/get")
# method
x$method
# uri
x$uri
# request signature to string
x$to_s()

# headers
w <- RequestSignature$new(
  method = "get",
  uri = "https:/httpbin.org/get",
  options = list(headers = list(`User-Agent` = "foobar", stuff = "things"))
)
w
w$headers
w$to_s()

# headers and body
bb <- RequestSignature$new(
  method = "get",
  uri = "https:/httpbin.org/get",
  options = list(
    headers = list(`User-Agent` = "foobar", stuff = "things"),
    body = list(a = "tables")
  )
)
bb
bb$headers
bb$body
bb$to_s()

# with disk path
f <- tempfile()
bb <- RequestSignature$new(
  method = "get",
  uri = "https:/httpbin.org/get",
  options = list(disk = f)
)
bb
bb$disk
bb$to_s()

Run the code above in your browser using DataLab