diff -Naur tbnl-0.4.0/modlisp.lisp tbnl-0.4.0a/modlisp.lisp
--- tbnl-0.4.0/modlisp.lisp	Mon Mar 14 16:42:30 2005
+++ tbnl-0.4.0a/modlisp.lisp	Tue Mar 15 17:05:57 2005
@@ -31,7 +31,7 @@
 
 (defun write-header-line (key value)
   "Accepts a KEY and a VALUE and writes them, one line at a time,
-to the mod_lisp or Araneida socket stream."
+to the mod_lisp or HTTP/araneida socket stream."
   (cond (*modlisp-headers*
          (write-header-line/modlisp key value))
         (t (write-header-line/http key value))))
@@ -279,38 +279,62 @@
                       (probe-file path))
               do (ignore-errors (delete-file path))))))
 
-#+:araneida
-(defun read-request-from-stream/tbnl (first-line &optional
-                                                 (default-hostname "localhost")
-                                                 (default-port *apache-port*))
-  (let ((araneida::*standard-araneida* nil)
-        (*modlisp-headers* nil))
-    (multiple-value-bind (method url-string protocol headers)
-        (araneida::read-request-from-stream/guts first-line default-hostname *apache-stream*)
-      (declare (ignorable method protocol))
-
-      ;(format t "   !!!! FIX THE CONSTANT DEFAULT-HOSTNAME~%")
-      
-      (push (cons "url" url-string) headers)
-      (push (cons "content-stream" *apache-stream*) headers)
-      (push (cons "server-ip-port" (format nil "~d" default-port)) headers)
-
-      (multiple-value-bind (result code)
-          (ignore-errors
-            (process-apache-command headers)
-            (force-output *apache-stream*))
-        (declare (ignorable code))
-        (when code (format t "Error in TBNL:: CODE ~S -- RESULT ~S~%" code result))
-        result))))
+(defun read-http-headers ()
+  (let ((headers nil))
+    (labels ((read-header-line ()
+               "Read a header line, considering continuations"
+               (with-output-to-string (header-line)
+                 (loop
+                  (let* ((line (read-line *apache-stream* t nil))
+                         (end (position #\Return line))
+                         (next (and (> end 0) (peek-char nil *apache-stream* nil nil))))
+                    (write-sequence line header-line :end end)
+                    (unless (or (eql next #\Space) (eql next #\Tab)) (return))))))
+             (split-header (line)
+               (unless (or (not line) (zerop (length line)))
+                 (destructuring-bind (key value) (cl-ppcre:split ":" line :limit 2)
+                   (cons (nstring-capitalize key) (string-trim " " value)))))       
+             (add-header (pair)
+               (let* ((existing-header (string-assoc (car pair) headers)))
+                 (if existing-header
+                     (rplacd (string-assoc (car pair) headers) (cdr pair))
+                   (push pair headers)))))
+      (loop
+       (let ((pair (split-header (read-header-line))))
+         (unless pair (return))
+         (add-header pair)))
+      headers)))
+        
+(defun read-http-request (first-line &optional (default-port *apache-port*))
+  (let ((*modlisp-headers* nil))
+      (destructuring-bind (method url-string &optional protocol)
+        (cl-ppcre:split " " first-line :limit 3)
+          (declare (ignorable method protocol))
+
+          (let ((headers (and protocol (read-http-headers))))
+            (push (cons "method" method) headers)
+            (push (cons "url" url-string) headers)
+            (when protocol (push (cons "server-protocol"
+                                       (string-trim '(#\Space #\NewLine #\Return) protocol))
+                                 headers))
+            (push (cons "content-stream" *apache-stream*) headers)
+            ;(push (cons "server-ip-port" (format nil "~d" default-port)) headers)
+
+            (multiple-value-bind (result code)
+                (ignore-errors
+                  (process-apache-command headers)
+                  (force-output *apache-stream*))
+              (declare (ignorable code))
+              (when code (format t "Error in TBNL:: CODE ~S -- RESULT ~S~%" code result))
+              result)))))
 
 (defun get-apache-command ()
   "Reads alternating key/value lines and posted content \(if any) from
 mod_lisp. Returns the results as an alist."
   (ignore-errors
-    #+:araneida
     (let ((first-line (read-line *apache-stream* nil nil)))
       (if (find #\Space first-line)
-          (read-request-from-stream/tbnl first-line)
+          (read-http-request first-line)
         (let ((second-line (read-line *apache-stream* nil nil)))
           (let* ((headers (loop for key = (read-line *apache-stream* nil nil)
                                 while (and key
@@ -322,18 +346,7 @@
             (when content-length
               (push (cons "content-stream" *apache-stream*)
                     headers))
-            headers))))
-    #-:araneida
-    (let* ((headers (loop for key = (read-line *apache-stream* nil nil)
-                                while (and key
-                                           (string-not-equal key "end"))
-                                for value = (read-line *apache-stream* nil nil)
-                                collect (cons key value)))
-                 (content-length (string-assoc "content-length" headers)))
-            (when content-length
-              (push (cons "content-stream" *apache-stream*)
-                    headers))
-            headers)))
+            headers))))))
 
 (defun apache-listen (*apache-stream* command-processor &rest args)
   "Listens on *APACHE-STREAM* for commands from mod_lisp. Packages the                                                                   
