CL-HTTP

CL-HTTP is a full-featured server for the Internet Hypertext Transfer Protocol (HTTP 1.1, HTML 2.0, HTML 3.2 & pre-HTML 4.0) that comes complete with source code. The server has been proven in major production systems and is a component of some interesting applications.

Web servers like CL-HTTP are ideal for building Semantic Web applications. One such application is, RacerPro, which is an OWL reasoner and inference server for the Semantic Web.

For an overview of the design ideas embodied in the CL-HTTP server see the paper by John C. Mallery. A description of Langtech’s extensions will appear shortly.

SBCL, EMACS, Hunchentoot and Cygwin

Here are my notes on setting up EMACS and SBCL for windows to work with CYGWIN. Once you have done this you can then install Hunchentoot. Hunchentoot is a web server that works quite well with SBCL. After following these instructions you should have a working lisp web server to play with.

Install CYGWIN into c:\cygwin and EMACS and SBCL into c:\home. Before you start cygwin edit your cygwin.bat file. I use the ‘C’ shell so my cygwin.bat file looks like this:

@echo off

C:
chdir C:\cygwin\bin
tcsh -l

Start CYGWIN and change to the root (‘/’) directory. Delete the existing home directory and create a symbolic link pointing to c:\home. At the SHELL prompt type

rmdir home
ln –s c:\home /home

In your home directory, mine is called VID, edit your .cshrc file and create a .emacs file containing the following:

;
(setq inferior-lisp-program “/home/sbcl/sbcl.exe
–core /home/sbcl/sbcl.core”)
(add-to-list `load-path “/home/sbcl/slime/”)
(require ’slime)
(slime-setup)

My .cshrc file looks like this:

alias emacs “/home/emacs/bin/runemacs.exe”
set path=($path /home/vid/bin)

In your HOME directory, create a bin directory. Change to this directory and create a file called sbcl containing:

#!/bin/csh
/cygdrive/c/home/sbcl/sbcl.exe –core c:\\home\\sbcl\\sbcl.core $*

Then at the shell prompt type

chmod +x sbcl; rehash

Now in your bin directory create a file called start-server containing

#!/bin/csh
sbcl –userinit /home/vid/bin/hunchentoot-test.lisp

The hunchentoot-test.lisp file that you need to create in your bin directory should contain the following:

(require :asdf)

(asdf:oos ‘asdf:load-op :hunchentoot)
(asdf:oos ‘asdf:load-op :hunchentoot-test)

(hunchentoot:start-server :port 4242)

You also need to edit the file c:\home\emacs\site-lisp\site-start.lisp. Mine contains just one line:

(setenv “HOME” “c:\\home\\vid\\”)

Download and install the following packages into c:\home\sbcl:

cffi
cffi-examples
cffi-tests
chunga
cl+ssl (see below)
cl-base64
cl-fad
cl-ppcre
cl-wh
flexi-streams
hunchentoot
hunchentoot-test
md5
rfc2388
slime
trivial-gray-streams
url-rewrite

You can download these packages from cliki. Put each of the downloaded packages into c:\home\sbcl and them just type

tar -xvzf <package-name.tar.gz>

You will need a different copy of cl+ssl. You can download cl+ssl from here. I made some minor changes to the original package so that the correct libraries are loaded by cffi. These libraries, libssl32.dll and libeay32.dll are included in the gzipped tar file clssl.tar.gz.

You will have to create the directories, cffi-examples, cffi-tests and hunchentoot-test, yourself. For simplicity I just copied cffi to cffi-test and to cffi-examples. Likewise I copied hunchentoot to hunchentoot–test. From a CYGWIN shell just type

cd /home/sbcl
cp –r cffi cffi-test
cp –r cffi cffi-examples
cp –r hunchentoot hunchentoot-test

Now you can do the following:

1) start cygwin and at the shell prompt type start-server. This will start hunchentoot. Point your browser at http://localhost:4242/

2) run emacs with sbcl as the inferior-lisp-program. When emacs has started type M-x slime. Sbcl should start.

Web Server Design

LISP is an ideal tool for developing Semantic Web Applications. On the server side there are two Web Servers that stand out. The first is CL-HTTP, described elsewhere on this blog. The second is Portable AllegroServe (AServe) from Franz Inc. AServe is an open source tool that runs on many platforms. AServe has these components:

  • HTTP/1.1 compliant web server capable of serving static and dynamic pages
  • HTML generation facility that seamlessly merges html tag printing with computation of dynamic content. The HTML generator matches perfectly with the HTML parser (which is in another project) to allow web pages to be read, modifed in Lisp and then regenerated.
  • HTTP client functions to access web sites and retrieve data.
  • Secure Socket Layer (SSL) for both the server and client.
  • Web Proxy facility with a local cache.
  • Comprehensive regression test suite that verifies the functionality of the client, server, proxy and SSL
  • high performance for static and dynamic web page delivery
  • Licensed under terms that ensure that it will always be open source and that encourages its use in commercial settings.
  • A new publish function that builds a page from static and dynamic data and handles caching of the result.
  • Access control mechanisms for publishing directories that gives the webmaster the ability to specify which files and directories in the tree should be visible.
  • The ability to run external CGI programs.
  • An improved virtual hosting system that supports different logging and error streams for each virtual host.

If you would like to experiment with AServe I suggest you download and install “LISP in a Box” (Lispbox). When you are developing server side applications you will probably want to install AllegroGraph from Franz Inc., as well.

Lispbox contains:

  • Emacs, the powerful, customizable text editor
  • A Common Lisp implementation of your choosing
  • SLIME, the Superior Lisp Integration Mode for Emacs
  • ASDF, Another System Definition Facility, used to load Common Lisp libraries.
  • The practical code from Practical Common Lisp ready to be loaded using ASDF.
  • Some glue code to make it all a bit easier to use.

AllegoGraph is “capable of processing billions of RDF triples, and is a modern, high-performance, persistent, disk-based RDF graph database with support for SPARQL, RDFS++, and Prolog reasoning from Java applications. The new features of version 3.0 form a unified “Activity Recognition” package for flexibly analyzing networks and events in large volumes of structured and unstructured data.”

For futher information about developing applications read the book “A Semantic Web Primer”. Web Programming with AServe can be read about here.