Learn R Programming

webmockr (version 0.1.0)

RequestSignature: General purpose request signature builder

Description

General purpose request signature builder

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.

options

  • body - body as a named list
  • headers - headers as a named list
  • proxies - proxies as a named list
  • auth - authentication details, as a named list

Details

Methods
to_s()
Request signature to a string return: a character string representation of the request signature

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
z <- RequestSignature$new(
  method = "get",
  uri = "https:/httpbin.org/get",
  options = list(headers = list(`User-Agent` = "foobar", stuff = "things"))
)
z
z$headers
z$to_s()

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

Run the code above in your browser using DataLab