Reference Manual | Next: Chapter 2. Installation and Configuration
CL-HTTP is the Common Lisp Hypermedia Server, a comprehensive web application framework developed since 1994 at the MIT Computer Science & Artificial Intelligence Laboratory by John C. Mallery, with contributions from the Lisp community. It is a complete, production-quality platform for building dynamic web applications in Common Lisp.
The CL-HTTP architecture and subsystems are described in these papers:
CL-HTTP provides:
The system is freely distributed with complete source code (portable and platform-specific) and has been proven in major production systems and top research laboratories.
CL-HTTP's architecture is built on several key design principles that distinguish it from other web servers and application frameworks.
CL-HTTP keeps all portable code free of implementation-specific
conditionalizations. Platform-specific code is isolated in two packages
— IPC and WWW-UTILS — that export a
unified interface. The portable HTTP package inherits
platform-specific functionality through the Common Lisp package system
without knowing which Lisp implementation it runs on. This design has
allowed CL-HTTP to be ported to eight Common Lisp implementations spanning
Lisp machines, workstations, and modern platforms.
CL-HTTP uses CLOS (the Common Lisp Object System) pervasively. URLs, server instances, authentication objects, conditions, log objects, and export types are all represented as CLOS classes. The Meta-Object Protocol (MOP) is used for class introspection, and generic functions define the extension protocols. New behavior is added by specializing methods, not by editing existing code.
Rather than relying on CGI scripts or template engines, CL-HTTP uses response functions — Lisp functions that compute HTTP responses directly. A response function receives the URL object and the HTTP stream, and writes the response using the full power of Common Lisp. This approach is more powerful than Java Servlets and eliminates the overhead of process creation and string-based inter-process communication.
(http:export-url #u"/my-page.html"
:computed
:response-function #'write-my-page
:expiration '(:interval 3600)
:keywords '(:example))
CL-HTTP generates HTML through Lisp macros rather than templates. Each
HTML element has a corresponding macro that handles proper nesting, attribute
generation, and output escaping. The macros compile down to efficient
write-string and write-char calls with no runtime
parsing. Multiple HTML standards are supported simultaneously through
layered packages (HTML2, HTML3.2, HTML4.0, HTML5).
(html:with-html-document (:stream stream)
(html:with-document-preamble (:stream stream)
(html:declare-title "Example" :stream stream))
(html:with-document-body (:stream stream)
(html:with-section-heading ("Hello" :stream stream)
(html:with-paragraph (:stream stream)
(write-string "Generated by CL-HTTP." stream)))))
CL-HTTP uses the defresource facility for pooling
frequently allocated objects: HTTP server instances, worker threads, I/O
buffers, and data cache entries. Objects are allocated from the pool,
used, and returned rather than freshly consed on each request. This
minimizes garbage collection pressure on the hot path.
Errors are represented as a hierarchy of Common Lisp conditions.
Network errors, HTTP status codes, authentication failures, and protocol
violations each have a corresponding condition class. The condition
system's restart mechanism allows fine-grained recovery: a worker thread
can catch a connection-lost condition, log it, clean up
resources, and return to the thread pool without crashing.
CL-HTTP is organized into a layered package hierarchy. Each package has a well-defined role and a controlled set of exports that constitute its public interface.
IPC — Internal TCP Package
tcp-stream.lisp.
No portable code references IPC directly; it is used only by
WWW-UTILS.
WWW-UTILS — Portability Bridge (~141 exports)
SB-THREAD,
SB-MOP, SB-POSIX on SBCL; MP,
SYSTEM, CLOS on LispWorks) plus IPC
and RESOURCES, then re-exports a unified interface for:
make-lock, with-lock-held,
current-process, atomic-incf
file-creation-date,
file-modification-date, file-length-in-bytes,
create-directories-recursively
%parse-internet-address,
local-host-domain-name, live-connection-p
with-binary-stream,
with-text-stream, with-crlf-stream
report-condition,
report-string
URL — Uniform Resource Locators (~285 exports)
WWW-UTILS. URL class hierarchy, interning, parsing,
name-string generation, export type management, and search URL handling. All
URL types (HTTP, HTTPS, FTP, Gopher, Mailto, News, WAIS, Telnet, RTSP) are
represented as CLOS classes with a rich protocol of generic functions.
HTTP — HTTP Server (~370 exports)
WWW-UTILS, URL, and HTML.
The core server: request processing, header parsing and generation, content
negotiation, virtual hosts, authentication realms, data caching, logging,
service management, and the export-url interface. Selected
symbols from WWW-UTILS are promoted into HTTP so
that application code can access them as http:make-lock,
http:enable-http-service, etc.
HTML generation is organized in a layered package hierarchy where each newer standard inherits from the previous one:
HTML2 — HTML 2.0 (nicknames: HTML,
NETSCAPE1.0)
HTML3.2 (nickname: HTML3)
HTML4.0 (nickname: HTML4)
HTML5
XHTML1.0
Application code typically uses HTML5 or HTML4.0,
which inherit all operators from earlier standards. The Netscape extension
packages (NS1.1, NS2.0, NS3.0,
NS4.0) provide server push, client pull, and proprietary Netscape
features.
W3P — WWW Presentation System (nickname:
WWW-PRESENT, ~85 exports)
define-presentation-type, and form-based input.
W4 — Web Walker (~32 exports)
SMTP — Simple Mail Transfer Protocol (~43 exports)
send-mail, send-mail-message, mailer conditions,
and the with-network-mail-host macro.
LAMBDA-IR — Information Retrieval (nicknames:
LR, INFORMATION-RETRIEVAL-SUBSTRATE, ~82 exports)
ST-JSON — JSON Library
json-object, json-array, json-key),
keyword tokenization, and a JSON-escaping output stream.
MARKDOWN — Markdown to HTML Converter
SCRIPT — Client-Side Scripts
The package dependency chain illustrates how platform-specific code is isolated from portable application code:
Implementation-Specific APIs
(sb-thread, sb-bsd-sockets, sb-gray, sb-mop, sb-posix on SBCL)
(mp, comm, stream, clos, system on LispWorks)
|
v
IPC (platform-specific networking)
|
v
RESOURCES (portable resource pooling)
|
v
WWW-UTILS (portability bridge)
|
v
URL (URL classes and protocols)
|
v
HTML2 -> HTML3.2 -> HTML4.0 -> HTML5 (generation)
|
v
HTTP (server core, uses WWW-UTILS + URL + HTML)
| | | |
v v v v
W3P W4 LAMBDA-IR SMTP
|
v
Application Code
The key invariant: HTTP and all packages above it in this
diagram contain no implementation-specific code. All platform
dependencies flow upward through WWW-UTILS and
IPC.
CL-HTTP uses logical pathnames with the HTTP logical host.
The table below shows the source directory layout.
| Component | Logical Pathname | Description |
|---|---|---|
| Server | http:server; |
Core HTTP server, URL handling, headers, HTML generation, authentication, logging |
| Client | http:client; |
HTTP client substrate |
| Proxy | http:proxy; |
Caching proxy, reverse proxy, SSL proxy |
| W3P | http:w3p; |
Presentation system |
| W4 | http:w4; |
Constraint-guided web walker |
| Lambda-IR | http:lambda-ir; |
Site indexing and information retrieval |
| SMTP | http:smtp; |
SMTP mailer |
| HTML Parser | http:html-parser; |
Streaming HTML parser with DOM registry |
| LLM Interface | http:llm; |
LLM provider interface and JSON library |
| MCP Server | http:llm;mcp; |
Model Context Protocol server and LMACS editor |
| Examples | http:examples; |
Configuration examples, export definitions, client examples |
| FTP | http:ftp; |
FTP client |
| CLIM | http:clim; |
CLIM-based GUI interfaces |
| Shared Utilities | http:mcl;server; |
Portable utilities: resources, www-utils, MD5 |
| Platform | Logical Pathname | Key Files |
|---|---|---|
| LispWorks | http:lw; |
server/, client/ — reference port |
| SBCL | http:sbcl; |
server/, client/, llm/, proxy/, w4/, patches/ |
| Symbolics Genera | http:lispm; |
server/, client/ — original implementation |
| CMU CL | http:cmucl; |
server/ |
| Allegro CL (OBC) | http:acl;obc; |
server/, client/ |
| Allegro CL (JKF) | http:acl;jkf; |
server/ |
| Scieneer CL | http:scl; |
server/ |
| MCL | http:mcl; |
server/ — also hosts portable utilities |
| Lucid CL | http:lcl; |
server/ |
Each platform-specific directory contains at minimum:
package.lisp (package augmentation),
tcp-stream.lisp (TCP streams and conditions),
unix.lisp (threading, file ops, utilities),
tcp-interface.lisp (service management and process pool),
and sysdcl.lisp (system definition).
| Platform | Status | Notes |
|---|---|---|
| LispWorks | Released | Reference port. Most complete and actively maintained. Windows, Linux, macOS, UNIX. Full HTTP/1.1, SSL/TLS, proxy, client, W3P, W4, LLM/MCP. |
| SBCL | Released | Newest full port. macOS, Linux, UNIX. Full HTTP/1.1, HTTP/2 server and client with reactor architecture, SSL/TLS via pure-tls, proxy, LLM/MCP. |
| Symbolics Genera | Released | Original implementation. Most sophisticated. Full HTTP/1.1, MCP server, Document Examiner integration. |
| CMU CL | Beta | UNIX. Useful reference for SBCL-family Lisps. |
| Allegro CL | Released | Two ports: OBC (released) and JKF (beta). Windows, Linux, macOS, UNIX. |
| Scieneer CL | Beta | Linux, UNIX. |
| MCL | Released | Macintosh Common Lisp. Hosts the portable utilities layer. |
| Lucid CL | Stale | Not updated since release 58.12. |
CL-HTTP uses Common Lisp *features* flags to control
conditional compilation of subsystems. Feature flags are pushed during
pre-initialization, before any CL-HTTP code loads.
| Feature | Purpose | When Pushed |
|---|---|---|
:cl-http |
CL-HTTP is loaded in the image | Automatically, in http:server;variables |
:multi-threaded |
The Lisp implementation supports threads | Always (required for CL-HTTP) |
:http-chunking |
Enable HTTP/1.1 chunked transfer encoding | When the TCP stream implementation supports chunking |
:cl-http-ssl |
Enable SSL/TLS server support | When the SSL interface is complete |
:cl-http-ssl-client |
Enable SSL/TLS client support | When the client SSL interface is complete |
:cl-http-x509 |
Enable X.509 certificate handling | When X.509 support is available |
:cl-http-file-author |
The platform supports file-author |
When POSIX file ownership is available |
:w3p |
W3P presentation system is loaded | Automatically, in http:w3p;package |
:w4 |
W4 web walker is loaded | Automatically, in http:w4;package |
:lambda-ir |
Lambda-IR information retrieval is loaded | Automatically, in http:lambda-ir;package |
The recommended approach for a new port is to start with only
:multi-threaded, bring up a working HTTP/1.0 server, then
progressively push :http-chunking (for HTTP/1.1) and
:cl-http-ssl (for HTTPS) as those subsystems are completed.
Code gated by these features compiles to nothing when the feature is absent,
allowing incremental bring-up.
Reference Manual | Next: Chapter 2. Installation and Configuration