參考: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 –