Gmane
From: Jeff Dalton <jeff <at> aiai.ed.ac.uk>
Subject: Re: Review of CL web server APIs: (1) Araneida
Newsgroups: gmane.lisp.web
Date: 2003-08-19 18:51:19 GMT (5 years, 45 weeks, 4 days, 16 hours and 55 minutes ago)
I can describe the O-Plan HTTP server.

* The O-Plan HTTP server

** Overview

The O-Plan HTTP server is a fairly simple HTTP server used chiefly as
part of an HTML interface to O-Plan, an AI planning system.  It is
single-threaded, although it does a fork/exec for some things.  It
runs only in KCL/GCL, because it uses the KCL C interface for select,
socket operations, some low-level fd operations, and getting the
status of child processes.

When it is used as part of O-Plan, they run as one Unix process
started by a CGI program.  The server then requests a free port
from the OS, and HTML produced by the planning system contains
URLs that refer to that port.  In this case, the server talks
with only one or two users who are developing and evaluating
a set of plans; and when they are finished, the whole thing
exits.  In the meantime, other users might start and use a
separate instance of O-Plan by following a link to the "startup"
CGI program.  The port numbers this act as a kind of "session id".
[This approach can cause problems with firewalls, but at the
time it was written firewalls were less common and less restrictive.]

** Configuration

Configuration is via a hash-table of "parameters" that maps keywords
to values, by designated special variables, or by redefining or
"advising" certain functions.  Parameters can be set by Lisp code
or by command-line arguments when the server is run.

** Request model

Requests are represented by http-request structs which contain
slots for such things as the HTTP method, the requested URI,
and a header a-list.

Handlers are functions.  A handler is assigned a subtree of the URL
space by calling (add-http-uri-interpretation root fn).  A handler
takes as arguments a path, an http-request, and a stream to use
for sending a reply.  The "path" corresponds to the PATH_INFO
of a CGI request.

There is also support for "query args" and for converting them to
appropriate Lisp types and checking that they are valid.  For
example, you can specify that an argument must be one of a set of
symbols or that it must be an integer within a certain range.
New query-argument types can be defined.  For example, for
certain planning domains, we define a type :city.

There is a utility for sending response headers.

** URI processing

URIs are represented as strings.  There are utility functions for
such things as breaking strings at delimiters and normalizing names
by removing "." and "..".

-- Jeff