sunet/doc/latex/url.tex

73 lines
2.1 KiB
TeX
Raw Normal View History

\chapter{Parsing and Processing URLs}\label{cha:url}
%
2005-04-10 11:17:50 -04:00
The \ex{url} module contains procedures to parse and unparse HTTP 1.1 Request-URIs.
2005-04-10 11:17:50 -04:00
\defun{url-string->http-url}{string}{http-url}
\begin{desc}
\ex{Url-string->http-url} parses the Request-URI \var{string} into a
\ex{http-url} record.
\end{desc}
2005-04-10 11:17:50 -04:00
\defun{http-url?}{thing}{boolean}
\begin{desc}
2005-04-10 11:17:50 -04:00
\ex{http-url?} is the predicate for the \ex{http-url} record.
\end{desc}
2005-04-10 11:17:50 -04:00
\defun{http-url-host}{http-url}{string or \sharpf}
\defunx{http-url-port}{http-url}{integer or \sharpf}
\defunx{http-url-path}{http-url}{list}
2005-04-10 11:17:50 -04:00
\defunx{http-url-query}{http-url}{string or \sharpf}
\begin{desc}
2005-04-10 11:17:50 -04:00
\ex{http-url-host}, \ex{http-url-port}, \ex{http-url-path} and
\ex{http-url-query} are the selectors for the \ex{http-url} record.
The \var{host} slot is a non-empty string or \sharpf.
The \var{port} slot is an integer or \sharpf.
The \var{path} slot is a list containing the Request-URI's path
split at slashes and \emph{unescaped}.
2005-04-10 11:17:50 -04:00
The \var{query} slot is an non-empty-string, still in its
\emph{escaped} representation, or \sharpf.
\end{desc}
%
2005-04-10 11:17:50 -04:00
Examples for Request-URI strings and the slots of the corresponding http-url record:
\begin{alltt}
"http://foo.bar.org:7777///foo%20foo//bar.htm?bulb%20bulb"
\(\Rightarrow\) "foo.bar.org" 7777 '("foo foo" "bar.htm") "bulb%20bulb"
"http://foo.bar.org/"
\(\Rightarrow\) "foo.bar.org" #f '() #f
"/foo%20foo//bar.htm?bulb%20bulb"
\(\Rightarrow\) #f #f '("foo foo" "bar.htm") "bulb%20bulb"
"/"
\(\Rightarrow\) #f #f '() #f
\end{alltt}
2005-04-10 11:17:50 -04:00
\defun{http-url->url-string}{http-url}{string}
\begin{desc}
\ex{http-url->url-string} unparses a http-url record into its
corresponding Request-URI.
\end{desc}
\defun{http-url-path->path-string}{http-url-path}{string}
\begin{desc}
2005-04-10 11:17:50 -04:00
\ex{http-url-path->url-string} unparses the http-url-path field of
an http-url record into its corresponding part of the Request-URI,
re-escaping the path.
\end{desc}
2005-04-10 11:17:50 -04:00
Example:
\begin{alltt}
'("foo foo" "bar.htm") \(\Rightarrow\) "/foo%20foo/bar.htm"
\end{alltt}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "man"
%%% End: