Utils-class {Rook} | R Documentation |
Class Utils
Description
A convenience object for working with various aspects of web requests and responses.
Methods
bytesize(string=NULL)
:Returns size in bytes for
string
, a character vector.unescape(s=NULL)
:returns the url decoded value of the character vector
s
. Also replaces the'+'
character with a space.status_code(status=NULL)
:returns integer value for the given HTTP
status
, which can either be numeric or or a character vector describing the status. Returnsas.integer(500)
ifstatus
is NULL.escape_html(string=NULL)
:replaces
"&"
,"<"
,">"
,"'"
, and'"'
with entity equivalents.raw.match(needle=NULL, haystack=NULL, all=TRUE)
:returns index position of
needle
inhaystack
. All matched indexes are returned by default.needle
is either a raw vector or character string.haystack
is a raw vector.parse_query(qs=NULL, d=DEFAULT_SEP)
:Creates a named list from the the query string
qs
.d
is the separator value and defaults to'[&;] *'
.rfc2822(ts=NULL)
:Formats
ts
in RFC2822 time.ts
must be aPOSIXt
object.escape(s=NULL)
:Transforms any non-printable characters found in
s
to their percent-encoded equivalents.build_query(params=NULL)
:Creates a query string from the named list given in
params
.timezero()
:Returns a
POSIXct
object set to UNIX epoch.set_cookie_header(header, key, value, expires, path, domain, secure, httpOnly)
:Sets an HTTP cookie header in the environment
header
. All arguments exceptexpires
are length 1 character vectors, whileexpires
must be aPOSIXct
object.delete_cookie_header(header, key, value, expires, path, domain, secure, httpOnly)
:Deletes the HTTP cookie header.
See Also
Examples
Utils$bytesize('foo')
Utils$escape('foo bar')
Utils$unescape('foo+bar')
Utils$escape_html('foo <bar>')
Utils$escape('foo <bar>')
Utils$escape('foo\n<bar>')
Utils$status_code('OK')
Utils$status_code('Found')
Utils$status_code('Not Found')
x <- Utils$parse_query('foo=1&bar=baz')
x
Utils$rfc2822(Sys.time())
Utils$timezero()
Utils$build_query(x)
rm(x)