Examples of HttpRequestInterceptor


Examples of org.apache.http.HttpRequestInterceptor

public class ClientGZipContentCompression {

    public final static void main(String[] args) throws Exception {
        DefaultHttpClient httpclient = new DefaultHttpClient();

        httpclient.addRequestInterceptor(new HttpRequestInterceptor() {
          
            public void process(
                    final HttpRequest request,
                    final HttpContext context) throws HttpException, IOException {
                if (!request.containsHeader("Accept-Encoding")) {
View Full Code Here

Examples of org.apache.http.HttpRequestInterceptor

        int port = this.localServer.getServicePort();
        this.localServer.register("*", new SimpleService());
       
        FaultyHttpClient client = new FaultyHttpClient();
       
        client.addRequestInterceptor(new HttpRequestInterceptor() {

            public void process(
                    final HttpRequest request,
                    final HttpContext context) throws HttpException, IOException {
                request.addHeader("my-header", "stuff");
View Full Code Here

Examples of org.apache.http.HttpRequestInterceptor

        int port = this.localServer.getServicePort();
        this.localServer.register("*", new SimpleService());
       
        FaultyHttpClient client = new FaultyHttpClient();
       
        client.addRequestInterceptor(new HttpRequestInterceptor() {

            public void process(
                    final HttpRequest request,
                    final HttpContext context) throws HttpException, IOException {
                request.addHeader("my-header", "stuff");
View Full Code Here

Examples of org.apache.http.HttpRequestInterceptor

    }

    @Test(expected=IllegalArgumentException.class)
    public void testRequestParameterCheck() throws Exception {
        final HttpClientContext context = HttpClientContext.create();
        final HttpRequestInterceptor interceptor = new RequestAuthCache();
        interceptor.process(null, context);
    }
View Full Code Here

Examples of org.apache.http.HttpRequestInterceptor

    }

    @Test(expected=IllegalArgumentException.class)
    public void testContextParameterCheck() throws Exception {
        final HttpRequest request = new BasicHttpRequest("GET", "/");
        final HttpRequestInterceptor interceptor = new RequestAuthCache();
        interceptor.process(request, null);
    }
View Full Code Here

Examples of org.apache.http.HttpRequestInterceptor

        authCache.put(this.target, this.authscheme1);
        authCache.put(this.proxy, this.authscheme2);

        context.setAttribute(HttpClientContext.AUTH_CACHE, authCache);

        final HttpRequestInterceptor interceptor = new RequestAuthCache();
        interceptor.process(request, context);
        Assert.assertSame(this.authscheme1, this.targetState.getAuthScheme());
        Assert.assertSame(this.creds1, this.targetState.getCredentials());
        Assert.assertSame(this.authscheme2, this.proxyState.getAuthScheme());
        Assert.assertSame(this.creds2, this.proxyState.getCredentials());
    }
View Full Code Here

Examples of org.apache.http.HttpRequestInterceptor

        authCache.put(this.target, this.authscheme1);
        authCache.put(this.proxy, this.authscheme2);

        context.setAttribute(HttpClientContext.AUTH_CACHE, authCache);

        final HttpRequestInterceptor interceptor = new RequestAuthCache();
        interceptor.process(request, context);
        Assert.assertNull(this.targetState.getAuthScheme());
        Assert.assertNull(this.targetState.getCredentials());
        Assert.assertNull(this.proxyState.getAuthScheme());
        Assert.assertNull(this.proxyState.getCredentials());
    }
View Full Code Here

Examples of org.apache.http.HttpRequestInterceptor

        context.setAttribute(HttpClientContext.HTTP_ROUTE, new HttpRoute(this.target, null, this.proxy, false));
        context.setAttribute(HttpClientContext.TARGET_AUTH_STATE, this.targetState);
        context.setAttribute(HttpClientContext.PROXY_AUTH_STATE, this.proxyState);
        context.setAttribute(HttpClientContext.AUTH_CACHE, null);

        final HttpRequestInterceptor interceptor = new RequestAuthCache();
        interceptor.process(request, context);
        Assert.assertNull(this.targetState.getAuthScheme());
        Assert.assertNull(this.targetState.getCredentials());
        Assert.assertNull(this.proxyState.getAuthScheme());
        Assert.assertNull(this.proxyState.getCredentials());
    }
View Full Code Here

Examples of org.apache.http.HttpRequestInterceptor

        context.setAttribute(HttpClientContext.PROXY_AUTH_STATE, this.proxyState);

        final AuthCache authCache = new BasicAuthCache();
        context.setAttribute(HttpClientContext.AUTH_CACHE, authCache);

        final HttpRequestInterceptor interceptor = new RequestAuthCache();
        interceptor.process(request, context);
        Assert.assertNull(this.targetState.getAuthScheme());
        Assert.assertNull(this.targetState.getCredentials());
        Assert.assertNull(this.proxyState.getAuthScheme());
        Assert.assertNull(this.proxyState.getCredentials());
    }
View Full Code Here

Examples of org.apache.http.HttpRequestInterceptor

        authCache.put(this.target, this.authscheme1);
        authCache.put(this.proxy, this.authscheme2);

        context.setAttribute(HttpClientContext.AUTH_CACHE, authCache);

        final HttpRequestInterceptor interceptor = new RequestAuthCache();
        interceptor.process(request, context);
        Assert.assertNull(this.targetState.getAuthScheme());
        Assert.assertNull(this.targetState.getCredentials());
        Assert.assertNull(this.proxyState.getAuthScheme());
        Assert.assertNull(this.proxyState.getCredentials());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.