Rivet Tcl Commands and Variables

var (get | list | exists | number | all)
The var command manipulates variables set by the user.
get varname ?default?
Returns the value of variable varname as a string (even if there are multiple values). If the variable doesn't exist as a GET or POST variable, the ?default? value is returned, otherwise an error is thrown.
list varname
Returns the value of variable varname as a list, if there are multiple values.
exists varname
Returns 1 if varname exists, 0 if it doesn't.
number
Returns the number of variables.
all
Return a list of variable names and values.
See the example.
upload (channel | save | data | exists | size | type | filename)
The upload command is for file upload manipulation. See the relevant Apache Directives to further configure the behavior of this Rivet feature.
channel uploadname
When given the name of a file upload uploadname, returns a Tcl channel that can be used to access the uploaded file.
save uploadname filename
Saves the uploadname in the file filename.
data uploadname
Returns data uploaded to the server. This is binary clean - in other words, it will work even with files like images, executables, compressed files, and so on.
size uploadname
Returns the size of the file uploaded.
type
If the Content-type is set, it is returned, otherwise, an empty string.
filename uploadname
Returns the filename on the remote host that uploaded the file.
names
Returns the variable names, as a list, of all the files uploaded.
Please see the upload example.
load_env ?array_name?
Load the array of environment variables into the specified array name. Uses array ::request::env by default.
As Rivet pages are run in the ::request namespace, it isn't necessary to qualify the array name for most uses - it's ok to access it as env.
load_headers array_name
Load the headers that come from a client request into the provided array name, or use headers if no name is provided.
load_cookies ?array_name?
Load the array of cookie variables into the specified array name. Uses array cookies by default.
include filename_name
Include a file without parsing it for processing tags <? and ?>. This is the best way to include an HTML file or any other static content.
parse filename
Like the Tcl source command, but also parses for Rivet <? and ?> processing tags. Using this command, you can use one .rvt file from another.
headers (set | redirect | add | type | numeric)
The headers command is for setting and parsing HTTP headers.
redirect uri
Redirect from the current page to a new URI. Must be done in the first block of TCL code.
setcookie -name cookie-name -value cookie-value ?-expires date/time? ?-domain domain? ?-path path? ?-secure?
This command is for setting cookies for the server to send to the client. cookie-name is the name of the cookie, cookie-value is the data associated with the cookie. -expires sets an expiration date for the cookie, and must be in the format 'DD-Mon-YY HH:MM:SS', -path sets the path for which the cookie is valid, and -secure specifies that the cookie is only to be transmitted if the connection is secure (HTTPS).
type content-type
This command sets the Content-type header returned by the script, which is useful if you wish to send content other than HTML with Rivet - PNG or jpeg images, for example.
set headername value
Set arbitrary header names and values.
makeurl filename
Create a self referencing URL from a filename. For example:
makeurl /tclp.gif
returns http://[hostname]:[port]/tclp.gif. where hostname and port are the hostname and port of the server in question.