next up previous contents
Next: SQL Up: The Ur/Web Standard Library Previous: Transactions   Contents

HTTP

There are transactions for reading an HTTP header by name and for getting and setting strongly typed cookies. Cookies may only be created by the $ \mathsf{cookie}$ declaration form, ensuring that they be named consistently based on module structure. For now, cookie operations are server-side only.

\begin{displaymath}\begin{array}{l}
\mathsf{con} \; \mathsf{http\_cookie} :: \m...
...mathsf{t} \to \mathsf{transaction} \; \mathsf{unit}
\end{array}\end{displaymath}

There are also an abstract $ \mathsf{url}$ type and functions for converting to it, based on the policy defined by [allow|deny] url directives in the project file.

\begin{displaymath}\begin{array}{l}
\mathsf{type} \; \mathsf{url} \\
\mathsf{...
...\mathsf{string} \to \mathsf{option} \; \mathsf{url}
\end{array}\end{displaymath}

$ \mathsf{bless}$ raises a runtime error if the string passed to it fails the URL policy.

It is possible to grab the current page's URL or to build a URL for an arbitrary transaction that would also be an acceptable value of a link attribute of the a tag. These are server-side operations.

\begin{displaymath}\begin{array}{l}
\mathsf{val} \; \mathsf{currentUrl} : \math...
...thsf{transaction} \; \mathsf{page} \to \mathsf{url}
\end{array}\end{displaymath}

Page generation may be interrupted at any time with a request to redirect to a particular URL instead.

\begin{displaymath}\begin{array}{l}
\mathsf{val} \; \mathsf{redirect} : \mathsf...
...\mathsf{url} \to \mathsf{transaction} \; \mathsf{t}
\end{array}\end{displaymath}

It's possible for pages to return files of arbitrary MIME types. A file can be input from the user using this data type, along with the $ \mathsf{upload}$ form tag. These functions and those described in the following paragraph are server-side.

\begin{displaymath}\begin{array}{l}
\mathsf{type} \; \mathsf{file} \\
\mathsf...
...\mathsf{fileData} : \mathsf{file} \to \mathsf{blob}
\end{array}\end{displaymath}

It is also possible to get HTTP request headers and environment variables, and set HTTP response headers, using abstract types similar to the one for URLs.

\begin{displaymath}\begin{array}{l}
\mathsf{type} \; \mathsf{requestHeader} \\ ...
...f{string} \to \mathsf{transaction} \; \mathsf{unit}
\end{array}\end{displaymath}

A blob can be extracted from a file and returned as the page result. There are bless and check functions for MIME types analogous to those for URLs.

\begin{displaymath}\begin{array}{l}
\mathsf{type} \; \mathsf{mimeType} \\
\ma...
...sf{mimeType} \to \mathsf{transaction} \; \mathsf{t}
\end{array}\end{displaymath}


next up previous contents
Next: SQL Up: The Ur/Web Standard Library Previous: Transactions   Contents
2014-07-14