- Detect empty request
authorMatthew Mondor <mmondor@pulsar-zone.net>
Sat, 13 Aug 2011 21:00:39 +0000 (21:00 +0000)
committerMatthew Mondor <mmondor@pulsar-zone.net>
Sat, 13 Aug 2011 21:00:39 +0000 (21:00 +0000)
- Log status and request

mmsoftware/cl/server/test-httpd.lisp

index 6d605be..c6b52c3 100644 (file)
@@ -1,4 +1,4 @@
-;;; $Id: test-httpd.lisp,v 1.4 2011/08/13 20:29:08 mmondor Exp $
+;;; $Id: test-httpd.lisp,v 1.5 2011/08/13 21:00:39 mmondor Exp $
 ;;;
 ;;; Test/exemple minimal HTTP server
 
@@ -86,6 +86,8 @@ You sent the following information:
           (return
             (values (cond
                       ((and (= nlines 0)
+                            (= (length words) 0)) :no-request)
+                      ((and (= nlines 0)
                             (= (length words) 2)
                             (string= "GET" (aref words 0)))
                        (push line lines)
@@ -97,13 +99,22 @@ You sent the following information:
 
     (write-string *response* client-stream)
 
+    (let ((client-info (format nil "[~A:~A] #~A"
+                              (address-string address) port
+                              (stream-fd client-stream))))
+      (log-line "= Status    : ~A: ~A" client-info status)
+      (log-line "= Request   : ~A: ~A" client-info (first lines))) 
+
     (format client-stream "Status: ~A~%~%" status)
     (format client-stream
-           "IP address: ~A~%IP Port   : ~A~%~%Request:~%~%"
+           "IP address: ~A~%IP Port   : ~A~%~%"
            (address-string address) port)
-    (loop
-       for line in lines
-       do (format client-stream "~A~%" line))
+
+    (unless (eq :no-request status)
+      (format client-stream "Request:~%~%")
+      (loop
+        for line in lines
+        do (format client-stream "~A~%" line)))
 
     (finish-output client-stream)))