参考:http://hc.apache.org/httpcomponents-client-ga/tutorial/html/httpagent.html#d4e1261自动处理中的Android gzip的HTTP响应
本页面说下面的代码将设置HttpClient
自动处理gzip的响应(透明的HttpClient
用户):
DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.addRequestInterceptor(new RequestAcceptEncoding());
httpclient.addResponseInterceptor(new ResponseContentEncoding());
然而,我在Android SDK中找不到RequestAcceptEncoding
和ResponseContentEncoding
类。他们是否错过了 - 我是否需要自己写这些?
正是我需要的 - 感谢也为参考到SyncService –
链接不起作用。请纠正它。 –
请记住,如果您使用的是旧版本的Apache HTTP客户端,则可能找不到'GzipDecompressingEntitiy'。您可以在此处获取该代码:http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/httpcore-contrib/src/main/java/org/apache/http/contrib/compress/GzipDecompressingEntity.java –