gop
gop

Reputation: 2200

Compress String before sending it to the server

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?

Upvotes: 1

Views: 1933

Answers (2)

Jayamohan
Jayamohan

Reputation: 12924

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);

Upvotes: 1

Lalith B
Lalith B

Reputation: 12239

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

Content-Encoding : gzip

Upvotes: 1

Related Questions