 
 (extend-protocol ISend
   String
-  (send [data ^Response response]
-    (.send response data))
+  (send [data ^Context ctx]
+    (let [^Response response (.getResponse ctx)]
+      (.send response data)))
 
   clojure.core.async.impl.channels.ManyToManyChannel
-  (send [data ^Response response]
+  (send [data ^Context ctx]
     (-> (stream/publisher data)
-        (send response)))
+        (send ctx)))
 
   manifold.stream.default.Stream
-  (send [data ^Response response]
+  (send [data ^Context ctx]
     (-> (stream/publisher data)
-        (send response)))
+        (send ctx)))
 
   futura.promise.Promise
-  (send [data ^Response response]
+  (send [data ^Context ctx]
     (-> (stream/publisher data)
-        (send response)))
+        (send ctx)))
 
   manifold.deferred.IDeferred
-  (send [data ^Response response]
+  (send [data ^Context ctx]
     (-> (stream/publisher data)
-        (send response)))
+        (send ctx)))
 
   CompletableFuture
-  (send [data ^Response response]
+  (send [data ^Context ctx]
     (-> (stream/publisher data)
-        (send response)))
+        (send ctx)))
 
   Publisher
-  (send [data ^Response response]
-    (->> (stream/publisher (map helpers/bytebuffer) data)
-         (.sendStream response)))
+  (send [data ^Context ctx]
+    (let [^Response response (.getResponse ctx)]
+      (->> (stream/publisher data)
+           (stream/transform (map helpers/bytebuffer))
+           (.stream ctx)
+           (.sendStream response))))
 
   InputStream
-  (send [data ^Response response]
+  (send [data ^Context ctx]
     (let [^bytes buffer (byte-array 1024)
-          ^ByteBuf buf (Unpooled/buffer (.available data))]
+          ^ByteBuf buf (Unpooled/buffer (.available data))
+          ^Response response (.getResponse ctx)]
       (loop [index 0]
         (let [readed (.read data buffer 0 1024)]
           (when-not (= readed -1)


(defmethod send! DefaultContext
  [^DefaultContext context data]
  (send data (:response context)))

(defmethod send! Response
  [^Response response data]
  (send data response))

(defmulti adapter
  "A polymorphic function for create the

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defprotocol ISend
  "A low level send abstraction."
  (send [data ctx] "Send data."))

(defprotocol IHandlerResponse
  (handle-response [_ context] "Handle the ratpack handler response."))
