bm1729
bm1729

Reputation: 2375

Send gzip requests with clj-http

How do I send a gzipped request using the dakrone/clj-http client? So far I have:

(http/post <<REDACTED>>
           {:body (->> <<REDACTED>>
                       cheshire.core/generate-string
                       .getBytes
                       clj-http.util/gzip)
            :content-type "application/json"
            :content-encoding "gzip"
            :as :json})

But elasticsearch (the server in my case) is giving 500 errors Illegal character ((CTRL-CHAR, code 31)): only regular white space.

Any ideas?

Upvotes: 0

Views: 501

Answers (2)

Tianxiang Xiong
Tianxiang Xiong

Reputation: 4101

:content-encoding is not a recognized keyword for clj-http. Try :header {"Content-Encoding" "gzip"} instead.

Upvotes: 0

Svante
Svante

Reputation: 51541

I guess that you need to enable HTTP compression on the server, e. g. in the Elasticsearch config:

http.compression: true 

Upvotes: 0

Related Questions