应该用于发送GZIP COM pressed JSON从Android的客户端到服务器是什么标题?端到、客户、服务器、标题

由网友(连笑都那么勉强)分享简介:这个问题是扩展的问题here.我现在用的是code 这里转载如下,以GZIP COM preSS一个的JSONObject 。 This question is extension to the question here. I am using the code here reproduced below to G...

这个问题是扩展的问题here.我现在用的是code 这里转载如下,以GZIP COM preSS一个的JSONObject

This question is extension to the question here. I am using the code here reproduced below to GZIP compress a 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();

我使用的是 DefaultHttpClient 发送此COM pressed的JSONObject到服务器(code是在我的控制)。

I am using a DefaultHttpClient to send this compressed JSONObject to server(the code is in my control).

我的提问

我应该在我的要求用什么标题?我使用 request.setHeader(内容型,应用/ JSON); 发送JSON到服务器

What header should I use in my request? I am using request.setHeader("Content-type", "application/json"); for sending JSON to server?

推荐答案

要通知您发送GZIP恩codeD数据的服务器,发送的内容编码的头,不是的接受编码。

To inform the server that you are sending gzip-encoded data, send the Content-Encoding header, not Accept-Encoding.

阅读全文

相关推荐

最新文章