Commit 40b40bfc6a882bef90227b6b582bc51a9b8230ec

Thomas de Grivel 2017-06-19T14:34:57

untabify

diff --git a/thot-epoll.lisp b/thot-epoll.lisp
index 21aa89a..4deee4b 100644
--- a/thot-epoll.lisp
+++ b/thot-epoll.lisp
@@ -32,21 +32,21 @@
     (set-nonblocking fd)
     (setf (get-agent fd) agent)
     (epoll:add *epoll-fd* fd
-	       (agent-epoll-events agent)
-	       :data-fd fd)))
+               (agent-epoll-events agent)
+               :data-fd fd)))
 
 ;;  Worker agent
 
 (defclass worker (agent)
   ((stream :reader worker-stream
-	   :type stream)
+           :type stream)
    (addr :initarg :addr
-	    :reader worker-addr)
+            :reader worker-addr)
    (request :initform nil
-	    :accessor worker-request
-	    :type (or null request))
+            :accessor worker-request
+            :type (or null request))
    (reply :initform nil
-	  :accessor worker-reply)))
+          :accessor worker-reply)))
 
 (defmethod agent-epoll-events ((agent worker))
   (logior epoll:+in+ epoll:+out+ epoll:+err+))
@@ -69,8 +69,8 @@
 
 (define-condition accept-error (error)
   ((acceptor :initarg acceptor
-	     :reader accept-error-acceptor
-	     :type acceptor)))
+             :reader accept-error-acceptor
+             :type acceptor)))
 
 (defmethod agent-error ((agent acceptor))
   (error 'accept-error :acceptor agent))
@@ -89,12 +89,12 @@
       (epoll-add acceptor))
     (epoll:wait (events fd *epoll-fd*)
       (let ((agent (get-agent fd)))
-	(cond ((not (= 0 (logand epoll:+err+ events)))
-	       (agent-error agent))
-	      ((not (= 0 (logand epoll:+in+ events)))
-	       (agent-in agent))
-	      ((not (= 0 (logand epoll:+out+ events)))
-	       (agent-out agent)))))))
+        (cond ((not (= 0 (logand epoll:+err+ events)))
+               (agent-error agent))
+              ((not (= 0 (logand epoll:+in+ events)))
+               (agent-in agent))
+              ((not (= 0 (logand epoll:+out+ events)))
+               (agent-out agent)))))))
 
 ;;  
 (defun acceptor-loop-epoll (fd)
diff --git a/thot-threaded.lisp b/thot-threaded.lisp
index e3b6d10..5666039 100644
--- a/thot-threaded.lisp
+++ b/thot-threaded.lisp
@@ -22,14 +22,14 @@
      (when (<= n (length *worker-threads*))
        (return))
      (let ((thread (bordeaux-threads:make-thread 'worker-thread
-						 :name "worker")))
+                                                 :name "worker")))
        (push thread *worker-threads*))))
 
 (defun join-worker-threads ()
   (setq *stop* t)
   (bordeaux-set:set-each (lambda (sockfd)
-			   (cffi-socket:shutdown sockfd t t))
-			 *worker-sockfds*)
+                           (cffi-socket:shutdown sockfd t t))
+                         *worker-sockfds*)
   (loop
      (when (endp *worker-threads*)
        (return))
@@ -38,7 +38,7 @@
 
 (defmacro with-worker-threads (count &body body)
   `(let ((*worker-threads* ())
-	 (*worker-sockfds* (make-instance 'bordeaux-set:set)))
+         (*worker-sockfds* (make-instance 'bordeaux-set:set)))
      (init-worker-threads ,count)
      (unwind-protect (progn ,@body)
        (join-worker-threads))))
diff --git a/thot.asd b/thot.asd
index c828758..8a388be 100644
--- a/thot.asd
+++ b/thot.asd
@@ -8,12 +8,12 @@
 
 (defsystem "thot"
   :depends-on ("babel"
-	       "bordeaux-queue"
-	       "bordeaux-set"
-	       "bordeaux-threads"
+               "bordeaux-queue"
+               "bordeaux-set"
+               "bordeaux-threads"
                "babel-stream"
                "cffi-socket"
-	       "cl-debug"
+               "cl-debug"
                "cl-stream"
                "fd-stream")
   :components
diff --git a/thot.lisp b/thot.lisp
index 9c2bce5..bb7b1dd 100644
--- a/thot.lisp
+++ b/thot.lisp
@@ -12,11 +12,11 @@
 
 (defclass request ()
   ((stream :initarg :stream
-	   :reader request-stream%
-	   :type stream)
+           :reader request-stream%
+           :type stream)
    (method :initarg :method
-	   :accessor request-method%
-	   :type symbol)
+           :accessor request-method%
+           :type symbol)
    (target :initarg :target
            :accessor request-target%
            :type string)
@@ -24,13 +24,13 @@
                  :accessor request-http-version%
                  :type string)
    (headers :initform (make-hash-table :test 'equalp :size 32)
-	    :reader request-headers%
-	    :type hash-table)
+            :reader request-headers%
+            :type hash-table)
    (uri :accessor request-uri%
-	:type string)
+        :type string)
    (query :initform nil
-	  :accessor request-query%
-	  :type string)))
+          :accessor request-query%
+          :type string)))
 
 (defvar *request*)
 
@@ -57,15 +57,15 @@
 (defun split-request-uri-and-query (request)
   (declare (type request request))
   (let* ((target (request-target% request))
-	 (target-? (position #\? target))
-	 (uri (if target-?
-		  (subseq target 0 target-?)
-		  target))
-	 (query (if target-?
-		    (subseq target target-?)
-		    nil)))
+         (target-? (position #\? target))
+         (uri (if target-?
+                  (subseq target 0 target-?)
+                  target))
+         (query (if target-?
+                    (subseq target target-?)
+                    nil)))
     (setf (request-uri% request) uri
-	  (request-query% request) query)))
+          (request-query% request) query)))
 
 (defun request-uri (&optional (request *request*))
   (declare (type request request))
@@ -180,11 +180,11 @@
 
 (defclass reply ()
   ((status :initform nil
-	   :accessor reply-status%)
+           :accessor reply-status%)
    (headers :initform nil
-	    :accessor reply-headers%)
+            :accessor reply-headers%)
    (headers-sent :initform nil
-		 :accessor reply-headers-sent%
+                 :accessor reply-headers-sent%
                  :type boolean)))
 
 (defvar *reply*)
@@ -236,12 +236,12 @@
     (status "200 OK"))
   (let ((headers (reply-headers)))
     (if (endp headers)
-	(setf (reply-headers) (list line))
-	(loop
-	   (when (endp (rest headers))
-	     (setf (rest headers) (list line))
-	     (return))
-	   (pop headers))))
+        (setf (reply-headers) (list line))
+        (loop
+           (when (endp (rest headers))
+             (setf (rest headers) (list line))
+             (return))
+           (pop headers))))
   (let ((stream (request-stream)))
     (write-sequence stream line)
     (write-sequence stream +crlf+)))
@@ -261,7 +261,7 @@
   (content (format nil "404 Not found
   
 The requested url ~S was not found on this server."
-		   (request-target))))
+                   (request-target))))
 
 (defun 404-not-found-handler ()
   '404-not-found)
@@ -272,18 +272,18 @@ The requested url ~S was not found on this server."
 (defun request-cont (request)
   (let ((handlers *url-handlers*)
         (*request* request)
-	(*reply* (make-instance 'reply)))
+        (*reply* (make-instance 'reply)))
     (loop
        (when (endp handlers)
-	 (return))
+         (return))
        (let* ((handler-func (pop handlers))
-	      (handler (funcall handler-func)))
-	 (when handler
-	   (when (debug-p (or :thot :http))
-	     (format t "~&~S -> ~S~%" handler-func handler))
-	   (funcall handler)
+              (handler (funcall handler-func)))
+         (when handler
+           (when (debug-p (or :thot :http))
+             (format t "~&~S -> ~S~%" handler-func handler))
+           (funcall handler)
            (flush (request-stream))
-	   (return))))
+           (return))))
     (if (string-equal "keep-alive" (request-header 'connection))
         :keep-alive
         nil)))