General purpose request signature builder
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())
Method print()
print method for the RequestSignature
class
Examples
# make request signature
x <- RequestSignature$new(method = "get", uri = "https:/httpbin.org/get")
# method
x$method
#> [1] "get"
# uri
x$uri
#> [1] "https:/httpbin.org/get"
# request signature to string
x$to_s()
#> [1] "GET: https:/httpbin.org/get"
# headers
w <- RequestSignature$new(
method = "get",
uri = "https:/httpbin.org/get",
options = list(headers = list(`User-Agent` = "foobar", stuff = "things"))
)
w
#> <RequestSignature>
#> method: GET
#> uri: https:/httpbin.org/get
#> headers:
#> User-Agent: foobar
#> stuff: things
w$headers
#> $`User-Agent`
#> [1] "foobar"
#>
#> $stuff
#> [1] "things"
#>
w$to_s()
#> [1] "GET: https:/httpbin.org/get with headers {User-Agent: foobar, stuff: things}"
# 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
#> <RequestSignature>
#> method: GET
#> uri: https:/httpbin.org/get
#> body:
#> a: tables
#> headers:
#> User-Agent: foobar
#> stuff: things
bb$headers
#> $`User-Agent`
#> [1] "foobar"
#>
#> $stuff
#> [1] "things"
#>
bb$body
#> $a
#> [1] "tables"
#>
bb$to_s()
#> [1] "GET: https:/httpbin.org/get with body {a: tables} with headers {User-Agent: foobar, stuff: things}"
# with disk path
f <- tempfile()
bb <- RequestSignature$new(
method = "get",
uri = "https:/httpbin.org/get",
options = list(disk = f)
)
bb
#> <RequestSignature>
#> method: GET
#> uri: https:/httpbin.org/get
#> disk: /tmp/RtmpQ4fJL1/file60f350caf0b
bb$disk
#> [1] "/tmp/RtmpQ4fJL1/file60f350caf0b"
bb$to_s()
#> [1] "GET: https:/httpbin.org/get"