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.

Transparent GZIP decompression only returns single line of document from response.

See original GitHub issue

I’m having an issue with transparent GZIP decompression.

I’m not sure if this is the webserver returning a weird response, I’m also not sure what kind of information you need from me in this case.

Basically, If I let OkHttp handle decompression transparently, it only returns a single line of the document from the response. However, when I handle decompression myself using a GZIPInputStream, and read from it using a BufferedReader from body().byteStream(), I get the entire document. This way also gives me connection leaked warnings in my Logcat output, even though I’m calling body().close() after every request. (Even if I don’t use the response body).

Please let me know if you need any more information, I would be happy to provide.

P.S. I’m working on adding code and a test case to this post instead of using links. Just wanted to get it up to get initial responses on whether I was just crazy or not. 😃

EDIT

After building a simple test case, using Eclipse/Java environment (instead of Android libraries). This issue is not present. In both cases, the entire document is fetched correctly. This issue only appears in the android app and for the specific server I am sending the request to, Response headers will be below…

Dependencies under gradle file.

dependencies { … compile ‘com.android.support:appcompat-v7:23.2.1’ compile ‘com.android.support:design:23.2.1’ compile ‘com.squareup.okhttp3:okhttp:3.2.0’ compile ‘com.android.support:support-v4:23.2.1’ }

Response headers from the site:

Cache-Control: private Content-Type: text/html; charset=utf-8 Vary: Accept-Encoding Server: Microsoft-IIS/7.5 Set-Cookie: ASP.NET_SessionId=<omitted>; path=/; HttpOnly X-AspNet-Version: 2.0.50727 X-Powered-By: ASP.NET Date: Sat, 19 Mar 2016 03:17:25 GMT OkHttp-Sent-Millis: 1458358005672 OkHttp-Received-Millis: 1458358005742

Again, this only happens in the android app, and only when sending the request to this specific website. If I send the request to google.com or facebook.com, it succeeds. But for some reason, everything works fine when not using the android libraries.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
swankjessecommented, Mar 19, 2016

And if you don’t trim?

0reactions
swankjessecommented, Mar 19, 2016

All good. Truncating logs are annoying. You might be interested in this: https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor

Read more comments on GitHub >

github_iconTop Results From Across the Web

Transparent decompression of stream - python - Stack Overflow
Just use the function defined in this answer to a related question: import gzip ... 'rb') if f.read(2) == '\x1f\x8b': f.seek(0) return gzip....
Read more >
Compression and decompression functions in SQL Server 2016
Decompress function returns a value with varbinary(max) data type, representing the decompressed value of the binary input argument using the ...
Read more >
Transcoding of gzip-compressed files | Cloud Storage
Decompressive transcoding allows you to store compressed versions of files in Cloud Storage, which reduces at-rest storage costs, while still serving the file...
Read more >
Using wget, What is the right command to get gzipped version ...
So you will end up with a single, gzipped file on disk, for the first page you hit, but no other content. i.e....
Read more >
Compression and Decompression | NGINX Plus
Compress server responses, or decompress them for clients that don't ... gzip on;. By default, NGINX compresses responses only with MIME type text/html...
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