Example usage for org.apache.http.protocol BasicHttpProcessor addResponseInterceptor

List of usage examples for org.apache.http.protocol BasicHttpProcessor addResponseInterceptor

Introduction

In this page you can find the example usage for org.apache.http.protocol BasicHttpProcessor addResponseInterceptor.

Prototype

public void addResponseInterceptor(HttpResponseInterceptor httpResponseInterceptor) 

Source Link

Usage

From source file:org.sonatype.nexus.proxy.storage.remote.httpclient.HttpClientUtil.java

/**
 * Creates and prepares an http client instance by using configuration present in {@link RemoteStorageContext}.
 * <p/>/*from   ww w . j  av a  2 s .  c om*/
 * This implies:<br/>
 * * setting up connection pool using number of connections specified by system property
 * {@link #CONNECTION_POOL_SIZE_KEY}<br/>
 * * setting timeout as configured for repository<br/>
 * * (if necessary) configure authentication<br/>
 * * (if necessary) configure proxy as configured for repository
 *
 * @param ctxPrefix context keys prefix
 * @param ctx       remote repository context
 * @param logger    logger
 */
static void configure(final String ctxPrefix, final RemoteStorageContext ctx, final Logger logger) {
    final DefaultHttpClient httpClient = new DefaultHttpClient(createConnectionManager(),
            createHttpParams(ctx)) {
        @Override
        protected BasicHttpProcessor createHttpProcessor() {
            final BasicHttpProcessor result = super.createHttpProcessor();
            result.addResponseInterceptor(new ResponseContentEncoding());
            return result;
        }
    };

    ctx.putContextObject(ctxPrefix + CTX_KEY_CLIENT, httpClient);

    configureAuthentication(httpClient, ctxPrefix, ctx, ctx.getRemoteAuthenticationSettings(), logger, "");
    configureProxy(httpClient, ctxPrefix, ctx, logger);

    // NEXUS-3338: we don't know after config change is remote S3 (url changed maybe)
    ctx.putContextObject(ctxPrefix + CTX_KEY_S3_FLAG, new BooleanFlagHolder());
}

From source file:com.android.exchange.service.EasServerConnection.java

private HttpClient getHttpClient(final long timeout) throws CertificateException {
    if (mClient == null) {
        final HttpParams params = new BasicHttpParams();
        HttpConnectionParams.setConnectionTimeout(params, (int) (CONNECTION_TIMEOUT));
        HttpConnectionParams.setSoTimeout(params, (int) (timeout));
        HttpConnectionParams.setSocketBufferSize(params, 8192);
        mClient = new DefaultHttpClient(getClientConnectionManager(), params) {
            @Override/*w w  w  .java 2 s  .  c o  m*/
            protected BasicHttpProcessor createHttpProcessor() {
                final BasicHttpProcessor processor = super.createHttpProcessor();
                processor.addRequestInterceptor(new CurlLogger());
                processor.addResponseInterceptor(new WbxmlResponseLogger());
                return processor;
            }
        };
    }
    return mClient;
}