Hello, why was Accept-Encoding header removed from...
# ask-questions
b
Hello, why was Accept-Encoding header removed from Kotlin SDK and what to do if we want to send it to server? otherwise there`s at least 3x traffic https://github.com/growthbook/growthbook-kotlin/commit/eca9521a0c79f5190a7fe009f4f4309f861df92d
a
Hi Giorgi — hey! From my research, the intent behind removing the manual
Accept-Encoding
header is to rely on the HTTP client’s automatic compression handling rather than hardcoding it in the SDK. In the source... • L*ine 53*: default client is created
private val client: OkHttpClient = OkHttpClient(),
Line 91: the request is executed
client.newCall(getRequest).enqueue(...)
Line 91 is where OkHttp would handle it automatically.
b
Thanks for the reply, it`s strange though because in iOS SDK it`s hardcoded...
p
Hi @brief-umbrella-80783 The
Accept-Encoding
header was removed from the
NetworkDispatcherOkHttp
dispatcher because OkHttp adds it automatically and handles decompression transparently. When the header was set manually, OkHttp disabled its automatic decompression and passed raw compressed bytes to the callback. And it led to a crash. For the
NetworkDispatcherKtor
, we created a PR that adds the
ContentEncoding
plugin, which handles both adding the header and decompressing responses automatically.
🙌 1