A Response
object represents represents the HTTP response that a
Beakr
sends when it gets an HTTP request. It is by convention, the
object is always referred to as res
(and the HTTP request is
req
).
headers
A list containing a key-value header list.
status
An integer HTTP status code.
body
Contains the response body.
setHeader(key, value)
Sets a key-value header, i.e. "Content-Type" = "text/html"
.
setContentType(type)
Sets the response content-type.
setStatus(status)
Sets the HTTP status code.
setBody(body)
Sets the body response.
redirect(url)
Sets the HTTP status to 302, "Found" and redirects to url
.
json(txt, auto_unbox = TRUE)
Applies a function to text convert to JSON and sets the content-type to JSON.
text(txt)
Sets the response body text.
structured(protocol)
Sets the response protocol, i.e. "http"
plot(plot_object, base64 = TRUE, ...)
Sets the response type to plot image output.
Response
setHeader()
Response$setHeader(key, value)
setContentType()
Response$setContentType(type)
setStatus()
Response$setStatus(status)
setBody()
Response$setBody(body)
redirect()
Response$redirect(url)
json()
Response$json(txt, auto_unbox = TRUE)
text()
Response$text(txt)
structured()
Response$structured(protocol)
plot()
Response$plot(plot_object, base64 = TRUE, ...)
clone()
The objects of this class are cloneable with this method.
Response$clone(deep = FALSE)
deep
Whether to make a deep clone.