在 Clojure 中将 BufferedInputStream 转换为字符串
Convert BufferedInputStream to String in Clojure
mock.request 将响应 :body 作为 BufferedInputStream 返回。我需要打印并将其作为字符串进行比较。如何转换?
当我尝试将响应作为消息传递给我的断言时,我看到了原始输出,例如
(is (= 200 (:status response) (:body response)))
=> #object[java.io.BufferedInputStream 0x211bdf40 java.io.BufferedInputStream@211bdf40]
相关 questions 是 Java 特定的。
只是slurp
它:
(slurp (:body response))
我倾向于使用https://github.com/ztellman/byte-streams:
(convert (:body res) String)
mock.request 将响应 :body 作为 BufferedInputStream 返回。我需要打印并将其作为字符串进行比较。如何转换?
当我尝试将响应作为消息传递给我的断言时,我看到了原始输出,例如
(is (= 200 (:status response) (:body response)))
=> #object[java.io.BufferedInputStream 0x211bdf40 java.io.BufferedInputStream@211bdf40]
相关 questions 是 Java 特定的。
只是slurp
它:
(slurp (:body response))
我倾向于使用https://github.com/ztellman/byte-streams:
(convert (:body res) String)