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


Java RequestAcceptEncoding类代码示例

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


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

示例1: getHttpClientBuilder

import org.apache.http.client.protocol.RequestAcceptEncoding; //导入依赖的package包/类
public static HttpClientBuilder getHttpClientBuilder() {
	// Common CacheConfig for both the JarCacheStorage and the underlying
	// BasicHttpCacheStorage
	final CacheConfig cacheConfig = CacheConfig.custom().setMaxCacheEntries(1000).setMaxObjectSize(1024 * 128)
			.build();

	RequestConfig config = RequestConfig.custom().setConnectTimeout(DEFAULT_TIMEOUT)
			.setConnectionRequestTimeout(DEFAULT_TIMEOUT).setSocketTimeout(DEFAULT_TIMEOUT).build();

	HttpClientBuilder clientBuilder = CachingHttpClientBuilder.create()
			// allow caching
			.setCacheConfig(cacheConfig)
			// Wrap the local JarCacheStorage around a BasicHttpCacheStorage
			.setHttpCacheStorage(new JarCacheStorage(null, cacheConfig, new BasicHttpCacheStorage(cacheConfig)))
			// Support compressed data
			// http://hc.apache.org/httpcomponents-client-ga/tutorial/html/httpagent.html#d5e1238
			.addInterceptorFirst(new RequestAcceptEncoding()).addInterceptorFirst(new ResponseContentEncoding())
			// use system defaults for proxy etc.
			.useSystemProperties().setDefaultRequestConfig(config);
	return clientBuilder;
}
 
开发者ID:ansell,项目名称:csvsum,代码行数:22,代码来源:JSONUtil.java

示例2: createHttpProcessor

import org.apache.http.client.protocol.RequestAcceptEncoding; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected BasicHttpProcessor createHttpProcessor() {
    BasicHttpProcessor result = super.createHttpProcessor();

    result.addRequestInterceptor(new RequestAcceptEncoding());
    result.addResponseInterceptor(new ResponseContentEncoding());

    return result;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:ContentEncodingHttpClient.java

示例3: createHttpProcessor

import org.apache.http.client.protocol.RequestAcceptEncoding; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected BasicHttpProcessor createHttpProcessor() {
    final BasicHttpProcessor result = super.createHttpProcessor();

    result.addRequestInterceptor(new RequestAcceptEncoding());
    result.addResponseInterceptor(new ResponseContentEncoding());

    return result;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:13,代码来源:ContentEncodingHttpClient.java

示例4: createInstance

import org.apache.http.client.protocol.RequestAcceptEncoding; //导入依赖的package包/类
/**
 * Creates an instance of <tt>DefaultHttpClient</tt> with a <tt>ThreadSafeClientConnManager</tt>.
 * @return an implementation of the <tt>HttpClient</tt> interface.
 */
public HttpClient createInstance() {
    LOGGER.debug("Creating a new instance of DefaultHttpClient with configuration -> {}", toString());

    // Create the connection manager which will be default create the necessary schema registry stuff...
    final PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager();
    connectionManager.setMaxTotal(maxTotalConnections);
    connectionManager.setDefaultMaxPerRoute(maxConnectionsPerRoute);

    // Set the HTTP connection parameters (These are in the HttpCore JavaDocs, NOT the HttpClient ones)...
    final HttpParams params = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(params, connectionTimeout);
    HttpConnectionParams.setLinger(params, linger);
    HttpConnectionParams.setSocketBufferSize(params, socketBufferSize);
    HttpConnectionParams.setSoKeepalive(params, soKeepAlive);
    HttpConnectionParams.setSoReuseaddr(params, soReuseAddr);
    HttpConnectionParams.setSoTimeout(params, soTimeout);
    HttpConnectionParams.setStaleCheckingEnabled(params, staleCheckingEnabled);
    HttpConnectionParams.setTcpNoDelay(params, tcpNoDelay);

    // Create the HttpClient and configure the compression interceptors if required...
    final DefaultHttpClient httpClient = new DefaultHttpClient(connectionManager, params);

    if (useCompression) {
        httpClient.addRequestInterceptor(new RequestAcceptEncoding());
        httpClient.addResponseInterceptor(new DeflateContentEncoding());
    }

    return httpClient;
}
 
开发者ID:hpe-idol,项目名称:java-aci-api-ng,代码行数:34,代码来源:HttpClientFactory.java

示例5: prepareHttpClient

import org.apache.http.client.protocol.RequestAcceptEncoding; //导入依赖的package包/类
private void prepareHttpClient(AbstractHttpClient client)
{
  client.getParams().setParameter(ClientPNames.HANDLE_REDIRECTS, true);
  client.addRequestInterceptor(new RequestAcceptEncoding());
  client.addResponseInterceptor(new ResponseContentEncoding());
  client.setRedirectStrategy(new BasicRedirectStrategy());
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:8,代码来源:HttpClientFactory.java

示例6: connect

import org.apache.http.client.protocol.RequestAcceptEncoding; //导入依赖的package包/类
@Override
public void connect() throws IOException {
    if (m_client != null) {
        return;
    }
    final HttpParams httpParams = new BasicHttpParams();
    if (m_request != null) {
        int timeout = m_request.getParameterAsInt("timeout");
        if (timeout > 0) {
            HttpConnectionParams.setConnectionTimeout(httpParams, timeout);
            HttpConnectionParams.setSoTimeout(httpParams, timeout);
        }
    }
    m_client = new DefaultHttpClient(httpParams);
    m_client.addRequestInterceptor(new RequestAcceptEncoding());
    m_client.addResponseInterceptor(new ResponseContentEncoding());
    if (m_request != null) {
        int retries = m_request.getParameterAsInt("retries");
        if (retries > 0) {
            m_client.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler() {
                @Override
                public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
                    if (executionCount <= getRetryCount() && (exception instanceof SocketTimeoutException || exception instanceof ConnectTimeoutException)) {
                        return true;
                    }
                    return super.retryRequest(exception, executionCount, context);
                }
            });
        }
        String disableSslVerification = m_request.getParameter("disable-ssl-verification");
        if (Boolean.parseBoolean(disableSslVerification)) {
            final SchemeRegistry registry = m_client.getConnectionManager().getSchemeRegistry();
            final Scheme https = registry.getScheme("https");
            try {
                SSLSocketFactory factory = new SSLSocketFactory(SSLContext.getInstance(EmptyKeyRelaxedTrustSSLContext.ALGORITHM), SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
                final Scheme lenient = new Scheme(https.getName(), https.getDefaultPort(), factory);
                registry.register(lenient);
            } catch (NoSuchAlgorithmException e) {
                log().warn(e.getMessage());
            }
        }
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:44,代码来源:HttpUrlConnection.java

示例7: DecompressingHttpClient

import org.apache.http.client.protocol.RequestAcceptEncoding; //导入依赖的package包/类
/**
 * Constructs a decorator to ask for and handle compressed
 * entities on the fly.
 * @param backend the {@link HttpClient} to use for actually
 *   issuing requests
 */
public DecompressingHttpClient(HttpClient backend) {
    this(backend, new RequestAcceptEncoding(), new ResponseContentEncoding());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:DecompressingHttpClient.java

示例8: DecompressingHttpClient

import org.apache.http.client.protocol.RequestAcceptEncoding; //导入依赖的package包/类
/**
 * Constructs a decorator to ask for and handle compressed
 * entities on the fly.
 * @param backend the {@link HttpClient} to use for actually
 *   issuing requests
 */
public DecompressingHttpClient(final HttpClient backend) {
    this(backend, new RequestAcceptEncoding(), new ResponseContentEncoding());
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:10,代码来源:DecompressingHttpClient.java


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