当前位置: 首页>>代码示例>>Java>>正文


Java DeflateDecompressingEntity类代码示例

本文整理汇总了Java中org.apache.http.client.entity.DeflateDecompressingEntity的典型用法代码示例。如果您正苦于以下问题:Java DeflateDecompressingEntity类的具体用法?Java DeflateDecompressingEntity怎么用?Java DeflateDecompressingEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DeflateDecompressingEntity类属于org.apache.http.client.entity包,在下文中一共展示了DeflateDecompressingEntity类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: process

import org.apache.http.client.entity.DeflateDecompressingEntity; //导入依赖的package包/类
@Override
public void process(HttpResponse response, HttpContext context) throws HttpException, IOException {
    HttpEntity entity = response.getEntity();
    if (entity != null) {
        Header contentEncoding = entity.getContentEncoding();
        if (contentEncoding != null) {
            HeaderElement[] codecs = contentEncoding.getElements();
            for (HeaderElement codec : codecs) {
                if (codec.getName().equalsIgnoreCase(GZIP)) {
                    response.setEntity(new GzipDecompressingEntity(response.getEntity()));
                    return;
                }
                if (codec.getName().equalsIgnoreCase(DEFLATE)) {
                    response.setEntity(new DeflateDecompressingEntity(response.getEntity()));
                    return;
                }
            }
        }
    }
}
 
开发者ID:polyglot-mark,项目名称:salesforce-plugin,代码行数:21,代码来源:HttpCompressionResponseInterceptor.java

示例2: handleContentEncoding

import org.apache.http.client.entity.DeflateDecompressingEntity; //导入依赖的package包/类
private void handleContentEncoding(HttpResponse response) throws ServletException {
	HttpEntity entity = response.getEntity();
	if (entity != null) {
		Header contentEncodingHeader = entity.getContentEncoding();
		if (contentEncodingHeader != null) {
			HeaderElement[] codecs = contentEncodingHeader.getElements();
			LOGGER.debug("Content-Encoding in response:");
			for (HeaderElement codec : codecs) {
				String codecname = codec.getName().toLowerCase();
				LOGGER.debug("    => codec: " + codecname);
				if ("gzip".equals(codecname) || "x-gzip".equals(codecname)) {
					response.setEntity(new GzipDecompressingEntity(response.getEntity()));
					return;
				} else if ("deflate".equals(codecname)) {
					response.setEntity(new DeflateDecompressingEntity(response.getEntity()));
					return;
				} else if ("identity".equals(codecname)) {
					return;
				} else {
					throw new ServletException("Unsupported Content-Encoding: " + codecname);
				}
			}
		}
	}
}
 
开发者ID:SAP,项目名称:cloud-connectivityproxy,代码行数:26,代码来源:ProxyServlet.java

示例3: process

import org.apache.http.client.entity.DeflateDecompressingEntity; //导入依赖的package包/类
/**
 * Handles the following {@code Content-Encoding}s by
 * using the appropriate decompressor to wrap the response Entity:
 * <ul>
 * <li>gzip - see {@link GzipDecompressingEntity}</li>
 * <li>deflate - see {@link DeflateDecompressingEntity}</li>
 * <li>identity - no action needed</li>
 * </ul>
 *
 * @param response the response which contains the entity
 * @param  context not currently used
 *
 * @throws HttpException if the {@code Content-Encoding} is none of the above
 */
public void process(
        final HttpResponse response,
        final HttpContext context) throws HttpException, IOException {
    HttpEntity entity = response.getEntity();

    // It wasn't a 304 Not Modified response, 204 No Content or similar
    if (entity != null) {
        Header ceheader = entity.getContentEncoding();
        if (ceheader != null) {
            HeaderElement[] codecs = ceheader.getElements();
            for (HeaderElement codec : codecs) {
                String codecname = codec.getName().toLowerCase(Locale.US);
                if ("gzip".equals(codecname) || "x-gzip".equals(codecname)) {
                    response.setEntity(new GzipDecompressingEntity(response.getEntity()));
                    if (context != null) context.setAttribute(UNCOMPRESSED, true);  
                    return;
                } else if ("deflate".equals(codecname)) {
                    response.setEntity(new DeflateDecompressingEntity(response.getEntity()));
                    if (context != null) context.setAttribute(UNCOMPRESSED, true);
                    return;
                } else if ("identity".equals(codecname)) {

                    /* Don't need to transform the content - no-op */
                    return;
                } else {
                    throw new HttpException("Unsupported Content-Coding: " + codec.getName());
                }
            }
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:46,代码来源:ResponseContentEncoding.java

示例4: handleCompressedEntity

import org.apache.http.client.entity.DeflateDecompressingEntity; //导入依赖的package包/类
public static HttpEntity handleCompressedEntity(HttpEntity entity) {
    org.apache.http.Header contentEncoding = entity.getContentEncoding();
    if (contentEncoding != null)
        for (HeaderElement e : contentEncoding.getElements()) {
            if (CONTENT_ENCODING_GZIP.equalsIgnoreCase(e.getName())) {
                return new GzipDecompressingEntity(entity);
            }

            if (CONTENT_ENCODING_DEFLATE.equalsIgnoreCase(e.getName())) {
                return new DeflateDecompressingEntity(entity);
            }
        }

    return entity;
}
 
开发者ID:mercadolibre,项目名称:java-restclient,代码行数:16,代码来源:HTTPCUtil.java

示例5: process

import org.apache.http.client.entity.DeflateDecompressingEntity; //导入依赖的package包/类
/**
 * Handles the following {@code Content-Encoding}s by
 * using the appropriate decompressor to wrap the response Entity:
 * <ul>
 * <li>gzip - see {@link GzipDecompressingEntity}</li>
 * <li>deflate - see {@link DeflateDecompressingEntity}</li>
 * <li>identity - no action needed</li>
 * </ul>
 *
 * @param response the response which contains the entity
 * @param  context not currently used
 *
 * @throws HttpException if the {@code Content-Encoding} is none of the above
 */
public void process(
        final HttpResponse response,
        final HttpContext context) throws HttpException, IOException {
    final HttpEntity entity = response.getEntity();

    // entity can be null in case of 304 Not Modified, 204 No Content or similar
    // check for zero length entity.
    if (entity != null && entity.getContentLength() != 0) {
        final Header ceheader = entity.getContentEncoding();
        if (ceheader != null) {
            final HeaderElement[] codecs = ceheader.getElements();
            boolean uncompressed = false;
            for (final HeaderElement codec : codecs) {
                final String codecname = codec.getName().toLowerCase(Locale.ENGLISH);
                if ("gzip".equals(codecname) || "x-gzip".equals(codecname)) {
                    response.setEntity(new GzipDecompressingEntity(response.getEntity()));
                    uncompressed = true;
                    break;
                } else if ("deflate".equals(codecname)) {
                    response.setEntity(new DeflateDecompressingEntity(response.getEntity()));
                    uncompressed = true;
                    break;
                } else if ("identity".equals(codecname)) {

                    /* Don't need to transform the content - no-op */
                    return;
                } else {
                    throw new HttpException("Unsupported Content-Coding: " + codec.getName());
                }
            }
            if (uncompressed) {
                response.removeHeaders("Content-Length");
                response.removeHeaders("Content-Encoding");
                response.removeHeaders("Content-MD5");
            }
        }
    }
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:53,代码来源:ResponseContentEncoding.java


注:本文中的org.apache.http.client.entity.DeflateDecompressingEntity类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。