Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5995815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:00:53+00:00 2026-05-23T00:00:53+00:00

This has really been annoying me and it is quite important for me to

  • 0

This has really been annoying me and it is quite important for me to find the problem here.
The android code below is not unzipping for me.

HttpClient client = new DefaultHttpClient();
        HttpGet get = new HttpGet("http://www**************/get.php");
        get.addHeader("Accept-Encoding", "gzip");
        try {                   
            HttpResponse response = client.execute(get);
            InputStream instream = response.getEntity().getContent();
            Header contentEncoding = response.getFirstHeader("Content-Encoding");
            //Log msg header
            Header[] header = response.getAllHeaders();
            for(Header i : header) {
                Log.d("TEST", i.getName() + ":" + i.getValue() );
            }
            if (contentEncoding.getValue().equalsIgnoreCase("gzip")) {
                Log.d("TEST", "Content is gzipped");
                try {
                    instream = new GZIPInputStream(instream);
                    processStream(instream);
                 } finally {
                     instream.close();
                 }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

Logcat output:

D/TEST    ( 1067): Date:Fri, 03 Jun 2011 05:18:33 GMT
D/TEST    ( 1067): Server:Apache
D/TEST    ( 1067): X-Powered-By:PHP/5.2.10
D/TEST    ( 1067): Content-Encoding:gzip
D/TEST    ( 1067): Content-Length:765
D/TEST    ( 1067): Connection:close
D/TEST    ( 1067): Content-Type:application/json
D/TEST    ( 1067): Content is gzipped

W/System.err( 1067): java.io.IOException: Unknown format
W/System.err( 1067):    at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:85)
W/System.err( 1067):    at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:66)
W/System.err( 1067):    at com.mannotron.gallery.GalleryExample$GetImages.doInBackground(GalleryExample.java:69)
W/System.err( 1067):    at com.mannotron.gallery.GalleryExample$GetImages.doInBackground(GalleryExample.java:1)
W/System.err( 1067):    at android.os.AsyncTask$2.call(AsyncTask.java:185)
W/System.err( 1067):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
W/System.err( 1067):    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
W/System.err( 1067):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
W/System.err( 1067):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
W/System.err( 1067):    at java.lang.Thread.run(Thread.java:1096)

edit: added php code

Server side php:

//ob_start('ob_gzhandler');
header("HTTP/1.1 200 OK");
header("Content-Type: application/json"); 
header("Content-Encoding: gzip"); 


$dbhost = "xxxxxx";
$dbname = "xxxxxx";
$user = "xxxxxx";
$pass = "xxxxxx";

//Open databse connection
$db = new mysqli($dbhost,$user,$pass,$dbname) or die('Error opening db');   


$query = "SELECT * FROM Spots; ";
$result = null;
$result = $db->query($query);
$data = array();
while($row = $result->fetch_assoc()) {
    $data [] = $row;
}
$spots = '{"spots":'.json_encode($data)."}";
echo gzencode($spots,FORCE_GZIP);

$db->close();   
//ob_flush();

?>

I have tried both gz_encode() and outputbuffering with gzip at the server end in php. Can anyone see what I’m doing wrong? Thanks for your time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:00:54+00:00Added an answer on May 23, 2026 at 12:00 am

    The stream looks wrong, as it should start with ‘1f8b’. The reason might be a stray ‘a’ in your php-file. But the posted samples seem to be all right.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This problem has been afflicting me for quite a while and it's been really
This has been annoying me for a while yet the solution must be really
This has been annoying me for a while in several XCode projects. I really
I've been having this really annoying thing happen the past few days, that has
I'm sure this has been answered before, but I really cannot find it. I
This is a really odd one that has been annoying me for some time,
I've been having a really annoying problem that I suspect is an Android ADT
I know this has a really simple explanation, but I've been spoiled by not
I've got a really annoying problem in Perl. Here is my code: if $password
I know this has been done many times before (some posts are really old

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.