Java – GZIP in Android

GZIP in Android… here is a solution to the problem.

GZIP in Android

I just wanted to ask about using HttpClient in Android to send gzip for post requests?

Where do I get the OutputStream to pass in GZIPOutputstream?

Is there any fragment?

Solution

Hello UseHttpUriRequest is shown below

 String urlval=" http"//www.sampleurl.com/";
    HttpUriRequest req = new HttpGet(urlval);
    req.addHeader("Accept-Encoding", "gzip");
    httpClient.execute(req);

Then examine the content-encoded response as follows:

InputStream is = response.getEntity().getContent();
Header contentEncoding = response.getFirstHeader("Content-Encoding");
if (contentEncoding != null && contentEncoding.getValue().equalsIgnoreCase("gzip")) {
    is = new GZIPInputStream(is);
}

Related Problems and Solutions