Java 无法让Android 2.3处理GZIp

Java 无法让Android 2.3处理GZIp,java,android,Java,Android,安卓2.3没有从我们的服务器上获取内容编码头,这有点问题 有关与2.2和2.3的比较,请参阅 所以,我正试图找到一个解决办法,让Android能够处理GZIP,目前它只是失败了。以下是连接逻辑: 任何帮助都很酷。非常感谢 URL test = null; try { test = new URL(url); } catch (MalformedURLException e1) { // TODO Auto-gene

安卓2.3没有从我们的服务器上获取内容编码头,这有点问题

有关与2.2和2.3的比较,请参阅

所以,我正试图找到一个解决办法,让Android能够处理GZIP,目前它只是失败了。以下是连接逻辑:

任何帮助都很酷。非常感谢

URL test = null;

try {
    test = new URL(url);
                } catch (MalformedURLException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }

                URLConnection connection = null;

                try {
                    connection = test.openConnection();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                InputStream stream = null;
                try {
                    stream = connection.getInputStream();
                    Log.d("HttpHelper","getContentEncoding: " + connection.getContentEncoding()); // RETURNING NULL ON 2.3
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

                if ("gzip".equals(connection.getContentEncoding())) { // NULL HERE ON 2.3
                    try {
                        stream = new GZIPInputStream(stream);
                        responseString = textHelper.getText(stream);
                        globallistener.onComplete(responseString);
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }