Retrofit + OkHttp + GZIP-ed JSON-open source projects square/okhttp

I’m new to Retrofit but it seems really powerful. Everything works fine with a normal JSON, but as soon as I try a GZIPed one I just get an error:

I/System.out(14883): ——retrofit.RetrofitError: retrofit.converter.ConversionException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1

Obviously the the gibberish symbols I see in the Log cannot be parsed as JSON.

I thought okHttp is catchig that gzip stuff correctly? What am I missing?

These jars are in my libs folder:


This way I’m starting the call:

public interface OvlService {
    void getOvls(Callback callback);
OkHttpClient okHttpClient = new OkHttpClient();
Executor executor = Executors.newCachedThreadPool();
RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint("http://my.domain") // The base API endpoint.
.setExecutors(executor, executor)
.setClient(new OkClient(okHttpClient))

OvlService ovlService = restAdapter.create(OvlService.class);

ovlService.getOvls(new Callback() {

    public void success(OvlWrapper arg0, Response arg1) {
        System.out.println("result: " + arg0.toString());

The result:-line is never shown, but instead I see lots of these stuff T�� �����=�Mk�A�G�4.��@��A�� in the RetrofitLog. What do I do wrong that the gzip is not decompressed? Thanks!


I tried it with a gzip file on my test server ( and I also tried it with the original api server ( Same result, but different headers:

Test server:

HTTP/1.1 200 OK
Accept-Ranges: bytes
Connection: close
Content-Length: 477
Content-Type: application/x-gzip
ETag: "2cc40cb-1dd-..."
Last-Modified: Tue, 08 Jul 2014 17:00:08 GMT
OkHttp-Received-Millis: 1404950522590
OkHttp-Response-Source: NETWORK 200
OkHttp-Selected-Transport: http/1.1
OkHttp-Sent-Millis: 1404950522533
Server: Apache

Original server:

HTTP/1.1 200 OK
Connection: Keep-Alive
Content-Type: application/json
Keep-Alive: timeout=4, max=1000
OkHttp-Received-Millis: 1404950697627
OkHttp-Response-Source: NETWORK 200
OkHttp-Selected-Transport: http/1.1
OkHttp-Sent-Millis: 1404950697002
Server: Apache
Transfer-Encoding: chunked
X-Powered-By: PHP/5.3.3-7+squeeze19