the_mafia
11/21/2024, 12:13 PMcompress("gzip")
doesn't change anything.
val client = HttpClient(CIO) {
install(ContentEncoding)
}
val payload: String = client.get("<https://google.com>").bodyAsText()
val res = <http://client.post|client.post>("<https://postman-echo.com/post>") {
compress("gzip")
setBody(payload)
}
println(res.bodyAsText())
Marcus Ilgner
11/21/2024, 12:17 PMMarcus Ilgner
11/21/2024, 12:24 PM<http://postman-echo.com|postman-echo.com>
in your case) and decoded by their server before it's actually processed by any logic. Then it might also compress the response (or not) which in turn would be decompressed transparently by the ktor client and passed back to your application in uncompressed form.
In HTTP terms, the Content-Encoding
header is processed separately and the data on the wire only conforms to the Content-Type
header after having undergone processing of Content-Encoding
. S.a. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encodingthe_mafia
01/08/2025, 4:18 PMinstall(ContentEncoding) {
mode = ContentEncodingConfig.Mode.All
deflate()
gzip()
}