   (println (format "body->h: '%s' '%s'" body (first body)))
   (first body))
 
-
-
 (defn h->b [hd] 
   "Called when decoding. Determines how to construct the body."
   (println (format "header h->b: '%s'" hd))
     (case hd
-      "gets" GETS
-      "get"  GET
-      "set" SET
-      "VALUE" VALUE
+      "gets"   GETS
+      "get"    GET
+      "set"    SET
+      "VALUE"  VALUE
       "STORED" STORED
-      "END" END
+      "END"    END
           ERRC))
-
-
 
 (defn b->h 
   "Called when encoding. Determines the header that is generated."

(defn cmd-gets-keys [decoded]
  (clojure.string/split (first (rest decoded)) #" "))

(defn debug-response [ch msg r]
  (do 
    (println msg r)
    (map #(enqueue ch %) r)))

(defn test-handle [ch ci cmd]
    (println "Processing command: " (first cmd) " from " ci)
    (condp = (first cmd)
      "SET" (enqueue ch ["STORED"]) 
      "GET" (do (enqueue ch ["VALUE" "abc" "123"]) (enqueue ch ["END" ""]))
      "GETS" (do (enqueue ch ["VALUE" "abc" "123"]) (enqueue ch ["END" ""]))
      (enqueue ch "error")))


(defn handler
  [ch ci]
  (receive-all ch (partial test-handle ch ci)))


;(def s (start-tcp-server handler {:port 10000 :frame MEMCACHE}))


;get <key>*\r\n
;gets <key>*\r\n
(defcodec GET ["get" CR])
(defcodec GETS ["gets" CR])

;VALUE <key> <flags> <bytes> [<cas unique>]\r\n<data block>\r\n
;VALUE <key> <flags> <bytes>\r\n<data block>\r\n
(defcodec VALUE ["VALUE" K V CR CR])

;END\r\n
(defcodec END ["END"])

(defcodec ERRC CR)

