2

from link we understand that automatic content decompression. is not supported.
So is below recipe good way to handle the gzip content ?

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();
                        }                   
                    
                }

Bhuvan
  • 4,028
  • 6
  • 42
  • 84
  • http://mail-archives.apache.org/mod_mbox/hc-httpclient-users/202009.mbox/%3CCAF4ab9Vw1_4N1Xm14i0Darn7-XTZjAcWRrJWF1TuJsyYz2%3D%2BPg%40mail.gmail.com%3E – Bhuvan Sep 02 '20 at 20:15

0 Answers0