Package org.apache.http

Examples of org.apache.http.HttpRequestInterceptor


        int port = this.localServer.getServiceAddress().getPort();
        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


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

            final HttpRequest request,
            final HttpContext context)
            throws IOException, HttpException {
        if (this.requestInterceptors != null) {
            for (int i = 0; i < this.requestInterceptors.size(); i++) {
                HttpRequestInterceptor interceptor =
                    (HttpRequestInterceptor) this.requestInterceptors.get(i);
                interceptor.process(request, context);
            }
        }
    }
View Full Code Here

    public static Test suite() {
        return new TestSuite(TestHttpExecutionContext.class);
    }

    public void testAddFirstRequestInterceptorNull() {
        HttpRequestInterceptor itcp = null;
        BasicHttpProcessor instance = new BasicHttpProcessor();

        instance.addRequestInterceptor(itcp, 0);
        int itcpCount = instance.getRequestInterceptorCount();
        assertEquals(0, itcpCount);
View Full Code Here

        assertEquals(0, itcpCount);
        assertEquals(null, instance.getRequestInterceptor(0));
    }

    public void testAddFirsRequestInterceptor() {
        HttpRequestInterceptor itcp1 = new HttpRequestInterceptor() {
           
            public void process(
                    HttpRequest request,
                    HttpContext context) throws HttpException, IOException {
            }
           
        };
        HttpRequestInterceptor itcp2 = new HttpRequestInterceptor() {
           
            public void process(
                    HttpRequest request,
                    HttpContext context) throws HttpException, IOException {
            }
View Full Code Here

        assertEquals(2, itcpCount);
        assertEquals(itcp2, instance.getRequestInterceptor(0));
    }

    public void testAddTailRequestInterceptorNull() {
        HttpRequestInterceptor itcp = null;
        BasicHttpProcessor instance = new BasicHttpProcessor();

        instance.addRequestInterceptor(itcp, 0);
        int itcpCount = instance.getRequestInterceptorCount();
        assertEquals(0, itcpCount);
View Full Code Here

        assertEquals(0, itcpCount);
        assertEquals(null, instance.getRequestInterceptor(itcpCount - 1));
    }

    public void testAddTailRequestInterceptor() {
        HttpRequestInterceptor itcp1 = new HttpRequestInterceptor() {
           
            public void process(
                    HttpRequest request,
                    HttpContext context) throws HttpException, IOException {
            }
           
        };
        HttpRequestInterceptor itcp2 = new HttpRequestInterceptor() {
           
            public void process(
                    HttpRequest request,
                    HttpContext context) throws HttpException, IOException {
            }
View Full Code Here

        assertEquals(itcp1, instance.getRequestInterceptor(0));
        assertEquals(itcp1, instance.getRequestInterceptor(itcpCount - 1));
    }

    public void testAddRequestInterceptorMiddleIndex() {
        HttpRequestInterceptor itcp1 = new TestHttpRequestInterceptorPlaceHolder();
        BasicHttpProcessor instance = new BasicHttpProcessor();
        instance.addRequestInterceptor(itcp1, 2);
    }
View Full Code Here

        instance.addRequestInterceptor(itcp1, 2);
    }

    public void testClearByClass() {
        // remove a present class
        HttpRequestInterceptor itcp1 = new TestHttpRequestInterceptorPlaceHolder();
        HttpRequestInterceptor itcp2 = new TestHttpRequestInterceptorPlaceHolder();
        HttpRequestInterceptor itcp3 = new HttpRequestInterceptor() {
           
            public void process(
                    HttpRequest request,
                    HttpContext context) throws HttpException, IOException {
            }
           
        };
        BasicHttpProcessor instance = new BasicHttpProcessor();
        instance.addRequestInterceptor(itcp1);
        instance.addRequestInterceptor(itcp2);
        instance.addRequestInterceptor(itcp3);
        instance.removeRequestInterceptorByClass(itcp1.getClass());
        assertEquals(1, instance.getRequestInterceptorCount());
        instance.removeRequestInterceptorByClass(itcp3.getClass());
        assertEquals(0, instance.getRequestInterceptorCount());

        // remove a not present class
        instance.addRequestInterceptor(itcp1);
        instance.addRequestInterceptor(itcp2);
View Full Code Here

        int port = this.localServer.getServiceAddress().getPort();
        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

TOP

Related Classes of org.apache.http.HttpRequestInterceptor

Copyright © 2018 www.massapicom. 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.