1

I am still a beginner in Android. I am currently sending large amount of data(json) from the android app to web server using HTTPClient. I found that HttpURLConnection supports decompression for request but is there any support or any way that I can upload a compress/gzipped json to the web server?

Is the only way to achieve this is to manually gzip the json string and put the gzipped string into in to the post?

user2763829
  • 793
  • 3
  • 10
  • 20

1 Answers1

0

You can add GZIP compression in your HTTP header.

HttpUriRequest request = new HttpGet(url);
request.addHeader("Content-Encoding", "gzip");
// ...
httpClient.execute(request);

You can check this link for more information

Community
  • 1
  • 1
sbajaj
  • 59
  • 4
  • Thanks for the link. From my understanding adding the `request.addHeader("Content-Encoding", "gzip");` will only indicate to the web server that this post have gzip content but it will not compress the data automatically. Did I get the wrong idea? – user2763829 Jul 28 '14 at 12:29