How do I use compression with ktor client? I added...
# ktor
m
How do I use compression with ktor client? I added an "Accept-Encoding: gzip, deflate" header to my requests, and now the responses I get are compressed. How do I make ktor decompress them?
e
Hi @Marcin Wisniowski, you can use
ContentEncoding
feature: https://api.ktor.io/1.2.4/io.ktor.client.features.compression/-content-encoding.html
c
Note that you don’t need to set Accept-Encoding header with this feature (it is set automatically)
m
I'm having a hard time enabling that, where do I enable it? It's not on the https://ktor.io/clients/http-client/features page.
m
https://ss.nohus.eu/14031/ac13d689 Not sure what am I doing wrong 😕
Do I need some separate artifact for this?
e
Yep:
:ktor-client:ktor-client-encoding-jvm:version
m
Works now, thank you!
e
Awesome 🙂
m
https://github.com/ktorio/ktor/issues/1189 Is this going to be fixed?
gzip()
doesn't work, only
deflate()
. 😐 Guess I will stick with
deflate()
, apparently it's faster anyway.
e
in case anybody else comes across this old thread:
gzip()
is working great for me once i added the deps
i spoke too soon: it’s broken when you get a ResponseException 😭
205 Views