$web:do_url returns the actual htext that will be displayed by $web:hdisplay. It expects the following arguments:
arg1 (url) = URL, e.g. something like
{"/1324"} or
{"/1324:page_web", "/hello young man"}
arg2 (valid_key) = a flag if key is valid, e.g. 1
arg3 (extra) = referer/client information (see above), e.g.
{"Referer: http://tecfamoo.unige.ch:7777..... }
arg4 (fetch) = defining whether the actual htext of only the header
is to be retrieved.
Let's examine headers only vs. actual htext first:
The fetch tag specifies whether the actual htext of the document needs
to be retrieved, or only the headers. This is important because we use
$web:do_url
to route requests both for the server header information and
for the html of the document.
See the lines in $login:get (MOOtiny's version of Sept 25 95)
38: fork (0)
39: $web:headdisplay($web:get_htext(req, rc, player, 0));
40: endfork
41: suspend(3);
42: keep web:hdisplay($web:get_htext(req, rc, player, 1));
$web:headdisplay is the verb that displays the server headers wheras
$web:hdisplay displays the htext to the user. We want the headers to be
displayed before anything else, so we fork that off and get it calling
:do_url and so on before anything else. We have a suspend(3); to make
sure that the headers get there before the html, even if the html takes
a very short time to be constructed.
Notice that the only difference between the arguments is the 4th
argument, which is the one that gets passed as 'fetch' to $web:do_url
.
In the first case, we don't want to bother with fetching the html, in
the second case, we do.
$web:do_url
first builds a html server header information that
tells the client what server we are and what kind of document is retrieved,
i.e. something like this:
{"HTTP/1.0 200 Document follows", "MIME-Version: 1.0", "Server: WOOM/1.0",
"Date: Thursday, 21-Sep-95 20:23:00 1995", "Content-type: text/html", ""}
One important thing is the Date: because clients use this to tell whether they can just reload something they have in their cache, or have to go and grab it all again.
Then, it generates the html (head of the page, htext ....).
:do_url can parse three types of url.
Using this information, it gets headers and htext and parses them to return a list of htext, headers, keep, where keep specifies whether the connection will be kept open for the sakes of server push.