使用 clj-http 发送 gzip 请求

问题描述 投票:0回答:2

如何使用 dakrone/clj-http 客户端发送 gzip 压缩请求?到目前为止我已经:

(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

有什么想法吗?

clojure gzip clj-http
2个回答
0
投票

我猜你需要在服务器上启用 HTTP 压缩,例如。 G。在 Elasticsearch 配置中:

http.compression: true 

0
投票

:content-encoding
不是
clj-http
的可识别关键字。试试
:header {"Content-Encoding" "gzip"}

© www.soinside.com 2019 - 2024. All rights reserved.