【发布时间】:2018-09-21 14:04:14
【问题描述】:
如何使用 dakrone/clj-http 客户端发送压缩请求?到目前为止,我有:
(http/post <<REDACTED>>
{:body (->> <<REDACTED>>
cheshire.core/generate-string
.getBytes
clj-http.util/gzip)
:content-type "application/json"
:content-encoding "gzip"
:as :json})
但是elasticsearch(我的服务器)给出了500个错误Illegal character ((CTRL-CHAR, code 31)): only regular white space。
有什么想法吗?
【问题讨论】:
-
FWIW 根据其test,您的呼叫看起来是正确的。没有 gzip 请求是否有效?
-
是的,删除 .getBytes、clj-http.util/gzip 和 :content-encoding "gzip" 给了我一个成功的请求。
-
你在测试中试过了吗?使用
clj-http.util/utf8-bytes明确您想要的编码或将其添加到.getBytes(但随后使用->而不是->>)