Package org.apache.http

Examples of org.apache.http.HttpRequestInterceptor.process()


        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


        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

        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

        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

        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

        this.targetState.update(new BasicScheme(), new UsernamePasswordCredentials("user3", "secret3"));
        this.proxyState.setState(AuthProtocolState.CHALLENGED);
        this.proxyState.update(new BasicScheme(), new UsernamePasswordCredentials("user4", "secret4"));

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

    @Test(expected=IllegalArgumentException.class)
    public void testRequestParameterCheck() throws Exception {
        final HttpContext context = new BasicHttpContext();
        final HttpRequestInterceptor interceptor = new RequestClientConnControl();
        interceptor.process(null, context);
    }

    @Test
    public void testConnectionKeepAliveForConnectRequest() throws Exception {
        final HttpRequest request = new BasicHttpRequest("CONNECT", "www.somedomain.com");
View Full Code Here

    public void testConnectionKeepAliveForConnectRequest() throws Exception {
        final HttpRequest request = new BasicHttpRequest("CONNECT", "www.somedomain.com");
        final HttpContext context = new BasicHttpContext();

        final HttpRequestInterceptor interceptor = new RequestClientConnControl();
        interceptor.process(request, context);
        final Header header1 = request.getFirstHeader("Proxy-Connection");
        Assert.assertNotNull(header1);
        Assert.assertEquals(HTTP.CONN_KEEP_ALIVE, header1.getValue());
        final Header header2 = request.getFirstHeader(HTTP.CONN_DIRECTIVE);
        Assert.assertNull(header2);
View Full Code Here

        final HttpRoute route = new HttpRoute(target, null, false);

        context.setAttribute(ClientContext.ROUTE, route);

        final HttpRequestInterceptor interceptor = new RequestClientConnControl();
        interceptor.process(request, context);

        final Header header1 = request.getFirstHeader(HTTP.CONN_DIRECTIVE);
        Assert.assertNotNull(header1);
        Assert.assertEquals(HTTP.CONN_KEEP_ALIVE, header1.getValue());
        final Header header2 = request.getFirstHeader("Proxy-Connection");
View Full Code Here

                TunnelType.TUNNELLED, LayerType.LAYERED);

        context.setAttribute(ClientContext.ROUTE, route);

        final HttpRequestInterceptor interceptor = new RequestClientConnControl();
        interceptor.process(request, context);

        final Header header1 = request.getFirstHeader(HTTP.CONN_DIRECTIVE);
        Assert.assertNotNull(header1);
        Assert.assertEquals(HTTP.CONN_KEEP_ALIVE, header1.getValue());
        final Header header2 = request.getFirstHeader("Proxy-Connection");
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.