This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-04-20
Channels
- # announcements (1)
- # asami (6)
- # babashka (21)
- # beginners (19)
- # calva (44)
- # circleci (3)
- # clj-http (3)
- # clj-kondo (44)
- # clojure (24)
- # clojure-australia (1)
- # clojure-czech (1)
- # clojure-europe (50)
- # clojure-france (5)
- # clojure-germany (1)
- # clojure-nl (2)
- # clojure-spec (8)
- # clojure-uk (8)
- # clojurescript (161)
- # datomic (4)
- # fulcro (7)
- # graalvm (8)
- # heroku (4)
- # lambdaisland (4)
- # lein-figwheel (5)
- # lsp (48)
- # malli (21)
- # meander (15)
- # off-topic (35)
- # polylith (2)
- # re-frame (21)
- # react (22)
- # reagent (13)
- # reitit (6)
- # remote-jobs (1)
- # reveal (3)
- # ring (3)
- # shadow-cljs (37)
- # testing (2)
- # tools-deps (10)
- # vim (18)
- # vrac (1)
- # xtdb (17)
I’m experimenting with vcr-clj (https://github.com/gfredericks/vcr-clj) and have noticed that the “cassette” text files appear to have an encoded response body, which means you can’t look at the cassettes to understand what the response says (assuming a JSON text response). Does anyone know of a way to make vcr-clj keep the response as unencoded text?
I'm not sure if there's an option for that - it will try to "Base64 encode" the response body to make it serializable. You can write some utility functions to decode that, e.g. https://github.com/jumarko/clojure-experiments/blob/master/src/clojure_experiments/networking.clj#L66-L88
(defn decode-body [base64-encoded-strings]
(-> base64-encoded-strings
vcr-serialization/maybe-join
codec/base64-decode
(String.)))
(with-open [r (java.io.PushbackReader. (io/reader (vcr-cassettes/cassette-file :record)))]
(let [as-edn (edn/read {:readers (assoc vcr-serialization/data-readers
'vcr-clj/input-stream decode-body)}
r)
body (-> as-edn :calls (get 0) :return :body)]
(println body)))
,)