                              (assoc memo (keyword k) (str/trim v))))
                       (sorted-map) headers)}))
 
-(defn compose [lines]
+(defn compose-list [lines]
+  "compose a list of lines with the proper line feeds and returns"
   (reduce
     (fn [res, el] (str/join (list res el "\r\n")))
     lines))
 
-(defmulti generate-response (fn [code _] code))
+(defmulti generate-response
+          "generate a response base on the response code given"
+          (fn [code _] code))
+
 (defmethod generate-response :404 [_ _]
   (let [page-content "<h1>404 Not Found</h1>"]
-    (compose
+    (compose-list
       (list
         "HTTP/1.1 404 Not Found"
         "Content-Type: text/html; charset=utf-8"

(ns inf4375-simple-server.core
  (:gen-class)
  (:import (java.io InputStreamReader PrintWriter BufferedReader ByteArrayOutputStream )
           (java.net ServerSocket))
  (:require [clojure.string :as str]
            [clojure.pprint :as pp]
            [me.raynes.fs   :as fs]))

(defn consume-buffer [input]
  (loop  [lines '()]
    (if (.ready input)
      (recur(concat lines (list (.readLine input))))
      (remove (fn [l] (empty? l))lines))))

(defn parse-request [lines]
  (let [[request-line & headers] lines
        [method uri version] (str/split request-line #" ")]
    {:request-line

        page-content))))

(defmethod generate-response :200 [_ res-as-string]
  (compose-list (list
             "HTTP/1.1 200 OK"
             "content-type: text/html; charset=utf-8"
             (format "content-length: %s" (count res-as-string))
