1

I want to minimize the size of my HTTP POST data sent from my android app to the server. The server runs on PHP. Can I utilize any compression method for that?

Lalith B
  • 11,843
  • 6
  • 29
  • 47
gop
  • 2,150
  • 5
  • 26
  • 54

2 Answers2

1

You can use GZip to compress your request. Android also supports GZip request. In that canse Your webserver would then need to handle gzip compression.

There were some SO Questions regarding how to GZip your request. You can refer to this post too, which says you can implement as below.

private static final String HEADER_ACCEPT_ENCODING = "Accept-Encoding";
private static final String ENCODING_GZIP = "gzip";
final DefaultHttpClient client = new DefaultHttpClient(manager, parameters);
Community
  • 1
  • 1
Jayamohan
  • 12,734
  • 2
  • 27
  • 41
1

You can use the compress and decompress the request and response using GZIP. You need to set the Request Headers

Content-Encoding : gzip
Community
  • 1
  • 1
Lalith B
  • 11,843
  • 6
  • 29
  • 47
  • Thanks. This should work. One more thing - how would you compare GZip to other compression techniques like 7zip in terms of string size reduction? Is there something better available for android? – gop Jan 02 '13 at 07:38
  • The following are supported in php refer manual http://php.net/manual/en/refs.compression.php also its only post variables so max length is about 4000chars if json is used. maximum of few kbs is sent, when compressing to gzip it reduces significantly the size. – Lalith B Jan 02 '13 at 07:43