https://kotlinlang.org logo
#ktor
Title
# ktor
s

ste

04/03/2022, 7:32 PM
Hi, is there an update regarding
br
(Brotli) support in
ktor-client-encoding
? The only thing I could find is https://github.com/ktorio/ktor/issues/408, but this is closed and the YouTrack link is broken
Solution:
Copy code
implementation("org.brotli:dec:0.1.2")
Copy code
install(ContentEncoding) {
           this.customEncoder(object : ContentEncoder {
               override val name = "br"

               override fun CoroutineScope.decode(source: ByteReadChannel): ByteReadChannel {
                   return BrotliInputStream(source.toInputStream()).toByteReadChannel()
               }

               override fun CoroutineScope.encode(source: ByteReadChannel): ByteReadChannel {
                    TODO()
               }
           })
        }
👍 1
a

Aleksei Tirman [JB]

04/04/2022, 8:09 AM
The issue in YouTrack now can be seeing by everyone but it contains the same comments as in Github issue.
👍 1
So unfortunately, Ktor doesn’t still have a support for Brotli encoder/decoder.
s

ste

04/04/2022, 9:28 AM
Fortunately it's very easy to use a third party encoder (probably not optimized for
ktor
, but whatever), but I have to use a 2017 release (https://github.com/google/brotli/issues/715)
a

Aleksei Tirman [JB]

04/04/2022, 9:40 AM
Yeah, the only problem is that it’s not multiplatform.
s

ste

04/04/2022, 9:43 AM
Yeah, also
189 Views