             [byte-streams :as bs]
             [manifold.deferred :as md]
             [promissum.core :as p]
+            [buddy.core.codecs :as codecs]
             [cats.core :as m]
             [cats.monad.exception :as exc]
             [catacumba.core :as ct]

        (is (= (:type response) :response))
        (is (= (:data response) {:foo [1]}))))))


    (pc/decode data :application/transit+json)))

(defn- send-raw-frame
  [uri method frame content-type]
  (let [headers {"content-type" content-type}]
    (condp = method
      :put (http/put uri {:body frame :headers headers})
      :get (http/get (str uri "?d=" (codecs/bytes->safebase64 frame))
                     {:headers headers}))))

(defn- send-frame
  ([uri frame]
   (send-frame uri frame :put))
  ([uri frame method]
   (let [data (pc/encode frame :application/transit+json)]
     @(md/chain
       (send-raw-frame uri method data "application/transit+json")
       response->frame))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Helpers
