1

链接我们了解到这automatic content decompression.是不支持的。
那么下面的配方是处理 gzip 内容的好方法吗?

httpclient.execute(this.post, new FutureCallback<SimpleHttpResponse>() {
                @Override
                public void completed(SimpleHttpResponse response) {                                        
                        String resXML = null;
                        
                        Header contentEncoding = response.getHeader("Content-Encoding");

                        if(contentEncoding != null 
                              && "gzip".equalsIgnoreCase(contentEncoding.getValue())){

                            HttpEntity entity = new GzipDecompressingEntity(new ByteArrayEntity(response.getBodyBytes(), ContentType.APPLICATION_XML));
                            resXML = EntityUtils.toString(entity, "UTF-8");

                        }else{
                            resXML = response.getBodyText();
                        }                   
                    
                }

4

0 回答 0