File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change 243243(defmethod coerce-response-body :json [req resp]
244244 (coerce-json-body req resp true ))
245245
246- (defmethod coerce-response-body :json-string-keys [_ resp]
247- (coerce-json-body resp false ))
246+ (defmethod coerce-response-body :json-string-keys [req resp]
247+ (coerce-json-body req resp false ))
248248
249249(defmethod coerce-response-body :clojure [_ {:keys [body] :as resp}]
250250 (if edn-enabled?
251251 (assoc resp :body (parse-edn (String. #^" [B" body " UTF-8" )))
252252 (binding [*read-eval* false ]
253253 (assoc resp :body (read-string (String. #^" [B" body " UTF-8" ))))))
254254
255- (defmethod coerce-response-body :auto [_ {:keys [body coerce status] :as resp}]
255+ (defmethod coerce-response-body :auto [req {:keys [body coerce status] :as resp}]
256256 (assoc resp
257257 :body
258258 (let [typestring (get-in resp [:headers " content-type" ])]
276276 json-enabled?)
277277 (if-let [charset (second (re-find #"charset=(.*)"
278278 (str typestring)))]
279- (coerce-json-body resp true charset)
280- (coerce-json-body resp true " UTF-8" ))
279+ (:body ( coerce-json-body req resp true charset) )
280+ (:body ( coerce-json-body req resp true " UTF-8" ) ))
281281
282282 :else
283283 (String. #^" [B" body " UTF-8" )))))
Original file line number Diff line number Diff line change 3030 {:status 200 :body " {:foo \" bar\" :baz #=(+ 1 1)}"
3131 :headers {" content-type" " application/clojure" }}
3232 [:get " /json" ]
33- {:status 200 :body " {\" foo\" :\" bar\" }" }
33+ {:status 200 :body " {\" foo\" :\" bar\" }" :headers { " content-type " " application/json " } }
3434 [:get " /json-bad" ]
3535 {:status 400 :body " {\" foo\" :\" bar\" }" }
3636 [:get " /redirect" ]
303303 (let [resp (client/get (localhost " /json" ) {:as :json })
304304 resp-str (client/get (localhost " /json" )
305305 {:as :json :coerce :exceptional })
306+ resp-auto (client/get (localhost " /json" ) {:as :auto })
306307 bad-resp (client/get (localhost " /json-bad" )
307308 {:throw-exceptions false :as :json })
308309 bad-resp-json (client/get (localhost " /json-bad" )
311312 bad-resp-json2 (client/get (localhost " /json-bad" )
312313 {:throw-exceptions false :as :json
313314 :coerce :unexceptional })]
314- (is (= 200 (:status resp) (:status resp-str)))
315- (is (= {:foo " bar" } (:body resp)))
315+ (is (= 200
316+ (:status resp)
317+ (:status resp-str)
318+ (:status resp-auto)))
319+ (is (= {:foo " bar" }
320+ (:body resp)
321+ (:body resp-auto)))
316322 (is (= " {\" foo\" :\" bar\" }" (:body resp-str)))
317323 (is (= 400
318324 (:status bad-resp)
You can’t perform that action at this time.
0 commit comments