我想知道我應該在gzip編碼響應的情況下做什麼。這是處理我的迴應的方法:解壓縮GZIP
private InputStream getResultStream(Response response) throws IOException
{
InputStream resultStream = null;
if(response != null)
{
String encoding = response.getHeader("Content-Encoding");
if((encoding != null) && (encoding.equalsIgnoreCase("gzip")))
{
// What to do here ?
Log.d("Stream :", "Read GZIP");
} else if ((encoding != null) && encoding.equalsIgnoreCase("deflate")) {
resultStream = new InflaterInputStream(response.getStream(), new Inflater(true));
Log.d("Stream :", "Read Deflated.");
} else {
resultStream = response.getStream();
Log.d("Stream :","Read Normal.");
}
}
return resultStream;
}
我該如何解決這個問題?
看看這個鏈接http://stackoverflow.com/q/6717165/779408。在那裏表示壓縮和解壓縮方法。 – breceivemail