/**
  * @param response
  * @param context
  * @throws HttpException
  * @throws IOException
  */
 public void process(final HttpResponse response, final HttpContext context)
     throws HttpException, IOException {
   final HttpEntity entity = response.getEntity();
   if (null != entity) {
     final Header encoding = entity.getContentEncoding();
     if (null != encoding) {
       for (HeaderElement codec : encoding.getElements()) {
         if (codec.getName().equalsIgnoreCase("gzip")) {
           response.setEntity(new GzipDecompressingEntity(response.getEntity()));
           return;
         }
       }
     }
   }
 }
Exemple #2
0
 public void process(final HttpResponse response, final HttpContext context)
     throws HttpException, IOException {
   HttpEntity entity = response.getEntity();
   if (entity != null) {
     Header ceheader = entity.getContentEncoding();
     if (ceheader != null) {
       HeaderElement[] codecs = ceheader.getElements();
       for (HeaderElement h : codecs) {
         if (h.getName().equalsIgnoreCase("deflate")) {
           response.setEntity(new DeflateDecompressingEntity(response.getEntity()));
           return;
         }
       }
     }
   }
 }
 /** get Charset String From HTTP Response */
 private String getCharsetFromEntity(HttpEntity entity, String defCharset) {
   final Header header = entity.getContentType();
   if (header != null) {
     final HeaderElement[] elements = header.getElements();
     if (elements.length > 0) {
       HeaderElement helem = elements[0];
       // final String mimeType = helem.getName();
       final NameValuePair[] params = helem.getParameters();
       if (params != null) {
         for (final NameValuePair param : params) {
           if (param.getName().equalsIgnoreCase("charset")) {
             String s = param.getValue();
             if (s != null && s.length() > 0) {
               return s;
             }
           }
         }
       }
     }
   }
   return defCharset == null ? Charsets.UTF_8 : defCharset;
 }