Possible Duplicate:
Android: HTTP communication should use “Accept-Encoding: gzip”
My Android application downloads temp.bin
file but today it (file) too big. I configured Apache to compress it to temp.bin.gz
by using gzip
. So i got 10% from actual size.
So far so good. Now the problem is how to decompress it in Android side during downloading.
I used before this snippets of download algorithm:
URL url = new URL(urlStr);
// set redirect mode ...
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setInstanceFollowRedirects(true);
connection.setConnectTimeout(0);
connection.setReadTimeout(0);
connection.setUseCaches(false);
connection.setAllowUserInteraction(false);
connection.connect();
....
InputStream in = null;
//boolean lengthValid = (contentLength != -1);
byte bytes[] = new byte[256];
int total_count = 0;
int max_count = 0;
try {
in = connection.getInputStream();
int count = 0;
while (count != -1){
count = in.read(bytes);
....
Any and all suggestions would be greatly appreciated.