| Response-class {Rook} | R Documentation |
Class Response
Description
A convenience class for creating Rook responses.
Methods
header(key, value):Sets an HTTP header for the response. Both
keyandvaluemust be character strings. Ifvalueis missing, then theheadervalue is returned.redirect(target, status=302):Sets up an HTTP redirect to the
targeturl.write(str):Takes a character vector and appends it to the response body.
new(body='', status=200, headers=list()):Create a new Response object.
bodyis a character vector,statusis an HTTP status value.headersis a named list.set_cookie(key, value):Sets an HTTP cookie for the response. Both
keyandvaluemust be character strings.delete_cookie(key, value):Sends appropriate HTTP header to delete the associated cookie on the client.
keyandvaluemust be character strings.finish():Returns the response according to the Rook specification.
See Also
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)
[Package Rook version 1.2 Index]