       (.setContent resp (formats/string->channel-buffer body)))
     resp))
 
+(defn- body-to-netty-chunk
+  [body]
+  (DefaultHttpChunk. (formats/string->channel-buffer body)))
+
 (defn- body-from-netty-req
   [^HttpMessage req]
   (.getContent req))


(defn- stream-or-finalize-resp
  [evt val req-state chan keepalive? streaming? last-write]
  (when (= :body evt)
    (throw (Exception. "Not implemented yet...")))

  (if keepalive?
    (swap! req-state (fn [[current args]]
                       (if (= current waiting-for-response)
                         [incoming-request args]
                         [current args true])))
    (.addListener last-write netty/close-channel-future-listener))
  (fn [& args] (throw (Exception. "This request is finished"))))

(defn- is-keepalive?
  [req-keepalive? hdrs]

   [org.jboss.netty.channel
    Channel]
   [org.jboss.netty.handler.codec.http
    DefaultHttpChunk
    DefaultHttpResponse
    HttpChunk
    HttpHeaders
