response | R Documentation |
Generally, you should not need to call this function directly; you'll
get a real HTTP response by calling req_perform()
and friends. This
function is provided primarily for testing, and a place to describe
the key components of a response.
response()
creates a generic response; response_json()
creates a
response with a JSON body, automatically adding the correct Content-Type
header.
response(
status_code = 200,
url = "https://example.com",
method = "GET",
headers = list(),
body = raw()
)
response_json(
status_code = 200,
url = "https://example.com",
method = "GET",
headers = list(),
body = list()
)
status_code |
HTTP status code. Must be a single integer. |
url |
URL response came from; might not be the same as the URL in the request if there were any redirects. |
method |
HTTP method used to retrieve the response. |
headers |
HTTP headers. Can be supplied as a raw or character vector which will be parsed using the standard rules, or a named list. |
body |
Response, if any, contained in the response body.
For |
An HTTP response: an S3 list with class httr2_response
.
response()
response(404, method = "POST")
response(headers = c("Content-Type: text/html", "Content-Length: 300"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.