A convenience class for creating Rook responses.
1.1
class
See Also
Rhttpd and Request.
Examples
s <- Rhttpd$new()## Not run:s$start(quiet=TRUE)## End(Not run)s$add(name="response", app=function(env){ req <- Request$new(env) res <- Response$new() res$write('hello') res$finish()})## Not run:s$browse('response')# Opens a browser window to the app.## End(Not run)s$remove(all=TRUE)rm(s)
Methods
header(key, value):: Sets an HTTP header for the response. Both key and value must be character strings. If value is missing, then the header value is returned.
redirect(target, status=302):: Sets up an HTTP redirect to the target url.
write(str):: Takes a character vector and appends it to the response body.
new(body='', status=200, headers=list()):: Create a new Response object. body is a character vector, status is an HTTP status value. headers is a named list.
set_cookie(key, value):: Sets an HTTP cookie for the response. Both key and value must be character strings.
delete_cookie(key, value):: Sends appropriate HTTP header to delete the associated cookie on the client. key and value must be character strings.
finish():: Returns the response according to the Rook specification.