这个问题是问题here的延伸.我使用下面复制的代码here来压缩一个JSONObject
.
String foo = "value";
ByteArrayOutputStream baos = new ByteArrayOutputStream();
GZIPOutputStream gzos = null;
try {
gzos = new GZIPOutputStream(baos);
gzos.write(foo.getBytes("UTF-8"));
} finally {
if (gzos != null) try { gzos.close(); } catch (IOException ignore) {};
}
byte[] fooGzippedBytes = baos.toByteArray();
I am using a DefaultHttpClient
to send this compressed JSONObject to server(the code is in my control).
My Question
What header should I use in my request
? I am using request.setHeader("Content-type", "application/json");
for sending JSON to server?