Utils-class: Class 'Utils'

Utils-classR 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. Returns as.integer(500) if status is NULL.

escape_html(string=NULL):

replaces "&", "<", ">", "'", and '"' with entity equivalents.

raw.match(needle=NULL, haystack=NULL, all=TRUE):

returns index position of needle in haystack. 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 a POSIXt 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 except expires are length 1 character vectors, while expires must be a POSIXct object.

delete_cookie_header(header, key, value, expires, path, domain, secure, httpOnly):

Deletes the HTTP cookie header.

See Also

Multipart.

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)

Rook documentation built on Nov. 10, 2022, 6:13 p.m.