UCW

The Backends 

A Trivial HTTP Server 

We don't actually expect anyone to use this backend but 1) it's convenient when getting starting and 2) the mod_lisp backend reuses most of it.

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defclass httpd-backend (backend)
    ((port :accessor port :initarg :port :initform 8080)
     (host :accessor host :initarg :host :initform "127.0.0.1")
     (socket :accessor socket)
     (server :accessor server :initarg :server)
     (handlers :accessor handlers :initform '())))
  
  (defclass httpd-message (message)
    ((headers :accessor headers :initform '())
     (network-stream :accessor network-stream :initarg :network-stream)))

  (defclass httpd-request (httpd-message request)
    ((parameters :accessor parameters :initform '())
     (raw-uri :accessor raw-uri)
     (query-path :accessor query-path)
     (raw-body :accessor raw-body :initform nil)
     (http-method :accessor http-method :initform nil)))

  (defclass httpd-response (httpd-message response)
    ((content-stream :accessor content-stream :initform (make-string-output-stream))
     (status :accessor status :initform "200 OK"))))

Backend methods

The single threaded server

Message headers methods

Request handling

helpers for parsing incoming http requests

Response objects

httpd-response objects special case the "Status" header.

Debugging the backend