Retrofit and OkHttp gzip decode

Replace this:

@Headers({
    "Accept-Encoding: gzip, deflate",
    "Content-Type: application/json;charset=utf-8",
    "Accept: application/json"
})

With this:

@Headers({
    "Content-Type: application/json;charset=utf-8",
    "Accept: application/json"
})

When you provide your own Accept-Encoding header you’re instructing OkHttp that you want to do your own decompression. By omitting it, OkHttp will take care of both adding the header and the decompression.

Leave a Comment