question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exception when accessing the content of a redirected URL

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:18 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
swankjessecommented, Mar 24, 2017

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();
0reactions
jniochecommented, May 15, 2017

Tried the snippet below with 3.8.0 and still 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:1005) at okio.RealBufferedSource.readByteArray(RealBufferedSource.java:107) at okhttp3.ResponseBody.bytes(ResponseBody.java:136) at Test.main(Test.java:18)

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

Here is the code

import java.io.IOException;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

public class Test {

    public static void main(String[] args) throws IOException {
 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());

    }

}
Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I redirect URL in case of exception or invalid input ...
I want to redirect the URL in case of exception or invalid input and return (print to the client) the exception with addition...
Read more >
How to Use JavaScript to Redirect a URL
Learn 3 of the most common ways to redirect a URL using JavaScript the location object: setting a new window.location.href property, ...
Read more >
Prevent open redirect attacks in ASP.NET Core
Whenever your application logic redirects to a specified URL, you must verify that the redirection URL hasn't been tampered with. ASP.
Read more >
How to Troubleshoot Browser Content Redirection
This could be due to the desired behavior as configured through BCR policies, or server fallback may have occurred unintentionally due to a...
Read more >
Redirect to the Previous URL After Login with Spring Security
2. Common Practice · using HTTP Referer header · saving the original request in the session · appending original URL to the redirected...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found