Example usage for org.apache.http.impl.client AbstractHttpClient removeRequestInterceptorByClass

List of usage examples for org.apache.http.impl.client AbstractHttpClient removeRequestInterceptorByClass

Introduction

In this page you can find the example usage for org.apache.http.impl.client AbstractHttpClient removeRequestInterceptorByClass.

Prototype

public synchronized void removeRequestInterceptorByClass(final Class<? extends HttpRequestInterceptor> clazz) 

Source Link

Usage

From source file:com.jayway.restassured.internal.http.ContentEncodingRegistry.java

/**
 * Add the request and response interceptors to the {@link HttpClient},
 * which will provide transparent decoding of the given content-encoding
 * types.  This method is called by HTTPBuilder and probably should not need
 * be modified by sub-classes.//w w  w  . j a  v  a 2 s .  c o  m
 *
 * @param client    client on which to set the request and response interceptors
 * @param encodings encoding name (either a {@link ContentEncoding.Type} or
 *                  a <code>content-encoding</code> string.
 */
void setInterceptors(final AbstractHttpClient client, Object... encodings) {
    // remove any encoding interceptors that are already set
    client.removeRequestInterceptorByClass(ContentEncoding.RequestInterceptor.class);
    client.removeResponseInterceptorByClass(ContentEncoding.ResponseInterceptor.class);

    for (Object encName : encodings) {
        ContentEncoding enc = availableEncoders.get(encName.toString());
        if (enc == null)
            continue;
        client.addRequestInterceptor(enc.getRequestInterceptor());
        client.addResponseInterceptor(enc.getResponseInterceptor());
    }
}