Java 类org.apache.http.client.protocol.ResponseContentEncoding 实例源码

项目:csvsum    文件:JSONUtil.java   
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;
}
项目:lams    文件:ContentEncodingHttpClient.java   
/**
 * {@inheritDoc}
 */
@Override
protected BasicHttpProcessor createHttpProcessor() {
    BasicHttpProcessor result = super.createHttpProcessor();

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

    return result;
}
项目:purecloud-iot    文件:ContentEncodingHttpClient.java   
/**
 * {@inheritDoc}
 */
@Override
protected BasicHttpProcessor createHttpProcessor() {
    final BasicHttpProcessor result = super.createHttpProcessor();

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

    return result;
}
项目:LibOppo    文件:OppoMessenger.java   
@SuppressFBWarnings("RV_RETURN_VALUE_IGNORED")
public OppoMessenger(final String remoteHost, final int remotePort, final int localPort,
                     final HttpClientService httpClient)
        throws IOException {
    this.httpClient = httpClient;

    // Set up the server
    final HttpProcessor processor = HttpProcessorBuilder.create()
            .add(new ResponseContent())
            .add(new ResponseContentEncoding())
            .add(new ResponseConnControl())
            .build();

    final HttpAsyncService service = new HttpAsyncService(processor, mapper);
    final NHttpConnectionFactory<DefaultNHttpServerConnection> connectionFactory = new DefaultNHttpServerConnectionFactory(ConnectionConfig.DEFAULT);
    final IOEventDispatch dispatch = new DefaultHttpServerIODispatch(service, connectionFactory);

    server = new DefaultListeningIOReactor(IOReactorConfig.DEFAULT);
    server.listen(new InetSocketAddress(localPort));

    new Thread(new Runnable() {
        @Override public void run() {
            try {
                server.execute(dispatch);
            } catch (final IOException e) {
                logger().level(Error).message("HTTP server failed").error(e).log();
            }
        }
    }, "Oppo HTTP server");

    // Set up the client
    deviceUrlBase = "http://" + remoteHost + ':' + remotePort + '/';
}
项目:BigSemanticsJava    文件:HttpClientFactory.java   
private void prepareHttpClient(AbstractHttpClient client)
{
  client.getParams().setParameter(ClientPNames.HANDLE_REDIRECTS, true);
  client.addRequestInterceptor(new RequestAcceptEncoding());
  client.addResponseInterceptor(new ResponseContentEncoding());
  client.setRedirectStrategy(new BasicRedirectStrategy());
}
项目:opennmszh    文件:HttpUrlConnection.java   
@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());
            }
        }
    }
}
项目:lams    文件:DecompressingHttpClient.java   
/**
 * 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());
}
项目:purecloud-iot    文件:DecompressingHttpClient.java   
/**
 * 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());
}