 
 
 
-
-

                             (assoc memo (keyword k) (str/trim v))))
                      (sorted-map) headers)}))

(defn run-server [port]
  (println (format "server accepting request on %s" port))
  (loop [server (new ServerSocket port)]

            in (new BufferedReader (new InputStreamReader (.getInputStream socket)))]
        (let [lines (consume-buffer in)]
          (if (not (empty? lines))
            (let [request (parse-request lines)]
              (pp/pprint request)
              (let [[_ & relative] ((request :request-line) :uri)]
                (if (and (not (empty? relative)) (fs/exists? (str/join relative)))
                  (.println out (generate-response :200 (slurp(str/join relative))))
                  (.println out (generate-response :404 nil)))))
            (.println out (generate-response :404 nil)))
          (.flush out)
          (.close out)
          (.close in)
          (.close socket)
          (recur server))))))


