okhttp: Exception when accessing the content of a redirected URL

Am getting

Exception in thread "main" java.io.IOException: ID1ID2: actual 0x00003c68 != expected 0x00001f8b
	at okio.GzipSource.checkEqual(GzipSource.java:205)
	at okio.GzipSource.consumeHeader(GzipSource.java:120)
	at okio.GzipSource.read(GzipSource.java:73)
	at okio.Buffer.writeAll(Buffer.java:996)
	at okio.RealBufferedSource.readByteArray(RealBufferedSource.java:106)
	at okhttp3.ResponseBody.bytes(ResponseBody.java:135)

when fetching https://sgs.taleo.net/careersection/qam/jobdetail.ftl?job=026018

Here is some code to reproduce the issue

        String url = args[0];
        
        OkHttpClient client = new OkHttpClient.Builder().followRedirects(false)
                .build();
        
        Request request = new Request.Builder().url(url).build();
        Response response = client.newCall(request).execute();
        
        System.out.println("body length "+response.body().bytes().length);
        System.out.println("code "+response.code());

I tried with Apache’s HTTPClient and it complains about java.util.zip.ZipException: Not in GZIP format

curl deals with it fine

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 18 (8 by maintainers)

Most upvoted comments

I wasn’t able to reproduce this. If you want to disable transparent gzip do this:

    Request request = new Request.Builder()
        .addHeader("Accept-Encoding", "identity")
        .url(url)
        .build();