This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-12-22
Channels
- # adventofcode (1)
- # beginners (172)
- # boot (47)
- # cider (7)
- # cljs-dev (30)
- # cljsrn (43)
- # clojure (180)
- # clojure-dusseldorf (1)
- # clojure-greece (1)
- # clojure-italy (3)
- # clojure-russia (41)
- # clojure-spec (67)
- # clojure-uk (101)
- # clojurescript (128)
- # core-async (4)
- # cursive (13)
- # datomic (29)
- # devcards (5)
- # emacs (19)
- # events (1)
- # hoplon (38)
- # lein-figwheel (1)
- # luminus (8)
- # midje (1)
- # off-topic (47)
- # om (10)
- # onyx (23)
- # protorepl (1)
- # re-frame (11)
- # reagent (7)
- # ring (3)
- # ring-swagger (9)
- # rum (6)
- # sql (5)
- # untangled (4)
I’m not interested in async everything and the parts that need it are already async, so that sounds good to me
Hello, I have encountered weird problem during testing, all responses from Peridot (HTTP mock lib based on ring-mock) are returned as java.io.ByteArrayInputStream
. I have pretty much standard set up - with my app
looking like this
(defapi app {:format [:json-kw :transit-json]
:swagger swagger-config} ; copypasta from tutorial
(middleware [mk-defaults]) ; XSS protection I am using in other projects
print-routes)
And the mocking part of the test is
(-> (session app)
(request "/fingerprint/api/register"
:request-method :post
:content-type "application/json"
:headers {"Accept" "application/json"} ; error is the same even without this header
:body body)
(:response)))
Strange thing here is that both request and response parts handle the body as InputStream and not as JSON.The very same thing works for me on other projects based just on Compojure/Luminus so I am not sure where could be a problem (and I am slowly getting desperate here)
btw it returns correct body when I call it from Swagger doc page (and generated curl command works as well)
@petr.mensik response body can be a stream, use (slurp body)
to convert it into a string
see Ring spec: https://github.com/ring-clojure/ring/blob/1d137e8b52b0c7ec81559199054e3d6e56128fb2/SPEC#L123
@metametadata got it but why is the result different when using plain curl
?
@petr.mensik the response should be the same, just packaged into a stream by ring-middleware-format. Ring-adapter can write both streams of string into the response stream and they look the same when viewed over http.
anyway, slurp works so thanks a lot 🙂