Request | R Documentation |
object that handled all aspects of a request
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 the 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
policies
(various) http policies, used in httr2 only
new()
Create a new Request
object
Request$new( method, uri, body, headers, opts, disk, fields, output, policies, skip_port_stripping = FALSE )
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
policies
(various) http policies, used in httr2 only
skip_port_stripping
(logical) whether to strip the port.
default: FALSE
A new Request
object
to_hash()
Convert the request to a list
Request$to_hash()
list
from_hash()
Convert the request to a list
Request$from_hash(hash)
hash
a list
a new Request
object
clone()
The objects of this class are cloneable with this method.
Request$clone(deep = FALSE)
deep
Whether to make a deep clone.
url <- "https://hb.opencpu.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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.