2003-01-15 07:21:18 -05:00
|
|
|
\chapter{Parsing and Processing URLs}\label{cha:url}
|
2002-02-12 06:50:54 -05:00
|
|
|
%
|
2005-04-10 11:17:50 -04:00
|
|
|
The \ex{url} module contains procedures to parse and unparse HTTP 1.1 Request-URIs.
|
2002-05-12 01:52:57 -04:00
|
|
|
|
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}
|
2002-02-12 06:50:54 -05:00
|
|
|
|
2005-04-10 11:17:50 -04:00
|
|
|
\defun{http-url?}{thing}{boolean}
|
2004-10-10 14:30:45 -04:00
|
|
|
\begin{desc}
|
2005-04-10 11:17:50 -04:00
|
|
|
\ex{http-url?} is the predicate for the \ex{http-url} record.
|
2004-10-10 14:30:45 -04:00
|
|
|
\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}
|
2003-01-15 07:21:18 -05:00
|
|
|
\defunx{http-url-path}{http-url}{list}
|
2005-04-10 11:17:50 -04:00
|
|
|
\defunx{http-url-query}{http-url}{string or \sharpf}
|
|
|
|
|
2002-02-12 06:50:54 -05:00
|
|
|
\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}.
|
2002-02-12 06:50:54 -05:00
|
|
|
|
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}
|
2003-01-15 07:21:18 -05:00
|
|
|
%
|
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}
|
2002-02-12 06:50:54 -05:00
|
|
|
|
2003-01-15 07:21:18 -05:00
|
|
|
|
2005-04-10 11:17:50 -04:00
|
|
|
\defun{http-url->url-string}{http-url}{string}
|
|
|
|
\begin{desc}
|
2005-04-10 11:30:32 -04:00
|
|
|
\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}
|
2003-01-15 07:21:18 -05:00
|
|
|
\begin{desc}
|
2005-04-10 11:30:32 -04:00
|
|
|
\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).
|
2003-01-15 07:21:18 -05:00
|
|
|
\end{desc}
|
2002-02-12 06:50:54 -05:00
|
|
|
|
|
|
|
%%% Local Variables:
|
|
|
|
%%% mode: latex
|
2002-08-21 10:52:34 -04:00
|
|
|
%%% TeX-master: "man"
|
2002-02-12 06:50:54 -05:00
|
|
|
%%% End:
|