sunet/doc/latex/url.tex

78 lines
2.3 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 of strings containing the
Request-URI's path split at slashes and \emph{unescaped}.If the
Request-URI's path ends with a slash, an empty string is inserted as
the last element of the list.
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}
%
Examples for Request-URI strings and the slots of the corresponding
http-url record: \nopagebreak
2005-04-10 11:17:50 -04:00
\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"
2005-04-10 11:17:50 -04:00
\(\Rightarrow\) "foo.bar.org" #f '() #f
"http://foo.bar.org//"
\(\Rightarrow\) "foo.bar.org" #f '("") #f
2005-04-10 11:17:50 -04:00
"/foo%20foo//bar.htm?bulb%20bulb"
\(\Rightarrow\) #f #f '("foo foo" "bar.htm") "bulb%20bulb"
"/foo%20foo//?bulb%20bulb"
\(\Rightarrow\) #f #f '("foo foo" "") "bulb%20bulb"
2005-04-10 11:17:50 -04:00
"/"
\(\Rightarrow\) #f #f '("") #f
2005-04-10 11:17:50 -04:00
\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 \ex{http-url} record and returns the
Request-URI \ex{string} of the original HTTP Request.
2005-04-10 11:17:50 -04:00
\end{desc}
\defun{http-url-path->path-string}{http-url-path}{string}
\begin{desc}
\ex{http-url-path->url-string} unparses the \ex{http-url-path} field of
an http-url record into its corresponding part of the Request-URI
\ex{string} of the original HTTP Request (re-escaping the path).
\end{desc}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "man"
%%% End: