The Ktor client provides the ContentEncoding plugin that allows you to enable specified compression algorithms (such as
deflate) and configure their settings. This plugin serves two primary purposes:
Accept-Encodingheader with the specified quality value.
Decodes content received from a server to obtain the original payload.
ContentEncoding, you need to include the
ktor-client-encoding artifact in the build script:
You can learn more about artifacts required by the Ktor client from Adding client dependencies.
ContentEncoding, pass it to the
install function inside a client configuration block:
The example below shows how to enable the
gzip encoders on the client with the specified quality values:
If required, you can implement the
ContentEncoder interface to create a custom encoder and pass it to the