Examples of HttpRoutePlanner


Examples of org.apache.http.conn.routing.HttpRoutePlanner

    }


    public void testDirect() throws Exception {

        HttpRoutePlanner hrp =
            new ProxySelectorRoutePlanner(createSchemeRegistry(),
                                          new ProxySelectorMockup(null));

        HttpHost target =
            new HttpHost("www.test.invalid", 80, "http");
        HttpRequest request =
            new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);

        HttpRoute route = hrp.determineRoute(target, request, null);

        assertEquals("wrong target", target, route.getTargetHost());
        assertEquals("not direct", 1, route.getHopCount());
    }
View Full Code Here

Examples of org.apache.http.conn.routing.HttpRoutePlanner

        List<Proxy> proxies = new ArrayList<Proxy>(2);
        proxies.add(new Proxy(Proxy.Type.HTTP, isa1));
        proxies.add(new Proxy(Proxy.Type.HTTP, isa2));

        HttpRoutePlanner hrp =
            new ProxySelectorRoutePlanner(createSchemeRegistry(),
                                          new ProxySelectorMockup(proxies));

        HttpHost target =
            new HttpHost("www.test.invalid", 80, "http");
        HttpRequest request =
            new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);

        HttpRoute route = hrp.determineRoute(target, request, null);

        assertEquals("wrong target", target, route.getTargetHost());
        assertEquals("not via proxy", 2, route.getHopCount());
        assertEquals("wrong proxy", isa1.getPort(),
                     route.getProxyHost().getPort());
View Full Code Here

Examples of org.apache.http.conn.routing.HttpRoutePlanner

    }


    public void testDirect() throws Exception {

        HttpRoutePlanner hrp =
            new ProxySelectorRoutePlanner(createSchemeRegistry(),
                                          new ProxySelectorMockup(null));

        HttpHost target =
            new HttpHost("www.test.invalid", 80, "http");
        HttpRequest request =
            new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);

        HttpRoute route = hrp.determineRoute(target, request, null);

        assertEquals("wrong target", target, route.getTargetHost());
        assertEquals("not direct", 1, route.getHopCount());
    }
View Full Code Here

Examples of org.apache.http.conn.routing.HttpRoutePlanner

        List<Proxy> proxies = new ArrayList<Proxy>(2);
        proxies.add(new Proxy(Proxy.Type.HTTP, isa1));
        proxies.add(new Proxy(Proxy.Type.HTTP, isa2));

        HttpRoutePlanner hrp =
            new ProxySelectorRoutePlanner(createSchemeRegistry(),
                                          new ProxySelectorMockup(proxies));

        HttpHost target =
            new HttpHost("www.test.invalid", 80, "http");
        HttpRequest request =
            new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);

        HttpRoute route = hrp.determineRoute(target, request, null);

        assertEquals("wrong target", target, route.getTargetHost());
        assertEquals("not via proxy", 2, route.getHopCount());
        assertEquals("wrong proxy", isa1.getPort(),
                     route.getProxyHost().getPort());
View Full Code Here

Examples of org.apache.http.conn.routing.HttpRoutePlanner

    }


    public void testDirect() throws Exception {

        HttpRoutePlanner hrp =
            new ProxySelectorRoutePlanner(createSchemeRegistry(),
                                          new ProxySelectorMockup(null));

        HttpHost target =
            new HttpHost("www.test.invalid", 80, "http");
        HttpRequest request =
            new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);

        HttpRoute route = hrp.determineRoute(target, request, null);

        assertEquals("wrong target", target, route.getTargetHost());
        assertEquals("not direct", 1, route.getHopCount());
    }
View Full Code Here

Examples of org.apache.http.conn.routing.HttpRoutePlanner

        List<Proxy> proxies = new ArrayList<Proxy>(2);
        proxies.add(new Proxy(Proxy.Type.HTTP, isa1));
        proxies.add(new Proxy(Proxy.Type.HTTP, isa2));

        HttpRoutePlanner hrp =
            new ProxySelectorRoutePlanner(createSchemeRegistry(),
                                          new ProxySelectorMockup(proxies));

        HttpHost target =
            new HttpHost("www.test.invalid", 80, "http");
        HttpRequest request =
            new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);

        HttpRoute route = hrp.determineRoute(target, request, null);

        assertEquals("wrong target", target, route.getTargetHost());
        assertEquals("not via proxy", 2, route.getHopCount());
        assertEquals("wrong proxy", isa1.getPort(),
                     route.getProxyHost().getPort());
View Full Code Here

Examples of org.apache.http.conn.routing.HttpRoutePlanner

                retryHandlerCopy = DefaultHttpRequestRetryHandler.INSTANCE;
            }
            execChain = new RetryExec(execChain, retryHandlerCopy);
        }

        HttpRoutePlanner routePlannerCopy = this.routePlanner;
        if (routePlannerCopy == null) {
            SchemePortResolver schemePortResolverCopy = this.schemePortResolver;
            if (schemePortResolverCopy == null) {
                schemePortResolverCopy = DefaultSchemePortResolver.INSTANCE;
            }
View Full Code Here

Examples of org.apache.http.conn.routing.HttpRoutePlanner

        // a null target may be acceptable, this depends on the route planner
        // a null context is acceptable, default context created below

        HttpContext execContext = null;
        RequestDirector director = null;
        HttpRoutePlanner routePlanner = null;
        ConnectionBackoffStrategy connectionBackoffStrategy = null;
        BackoffManager backoffManager = null;

        // Initialize the request execution context making copies of
        // all shared objects that are potentially threading unsafe.
        synchronized (this) {

            final HttpContext defaultContext = createHttpContext();
            if (context == null) {
                execContext = defaultContext;
            } else {
                execContext = new DefaultedHttpContext(context, defaultContext);
            }
            final HttpParams params = determineParams(request);
            final RequestConfig config = HttpClientParamConfig.getRequestConfig(params);
            execContext.setAttribute(ClientContext.REQUEST_CONFIG, config);

            // Create a director for this request
            director = createClientRequestDirector(
                    getRequestExecutor(),
                    getConnectionManager(),
                    getConnectionReuseStrategy(),
                    getConnectionKeepAliveStrategy(),
                    getRoutePlanner(),
                    getProtocolProcessor(),
                    getHttpRequestRetryHandler(),
                    getRedirectStrategy(),
                    getTargetAuthenticationStrategy(),
                    getProxyAuthenticationStrategy(),
                    getUserTokenHandler(),
                    params);
            routePlanner = getRoutePlanner();
            connectionBackoffStrategy = getConnectionBackoffStrategy();
            backoffManager = getBackoffManager();
        }

        try {
            if (connectionBackoffStrategy != null && backoffManager != null) {
                final HttpHost targetForRoute = (target != null) ? target
                        : (HttpHost) determineParams(request).getParameter(
                                ClientPNames.DEFAULT_HOST);
                final HttpRoute route = routePlanner.determineRoute(targetForRoute, request, execContext);

                final CloseableHttpResponse out;
                try {
                    out = CloseableHttpResponseProxy.newProxy(
                            director.execute(target, request, execContext));
View Full Code Here

Examples of org.apache.http.conn.routing.HttpRoutePlanner

        // a null target may be acceptable, this depends on the route planner
        // a null context is acceptable, default context created below

        HttpContext execContext = null;
        RequestDirector director = null;
        HttpRoutePlanner routePlanner = null;
        ConnectionBackoffStrategy connectionBackoffStrategy = null;
        BackoffManager backoffManager = null;

        // Initialize the request execution context making copies of
        // all shared objects that are potentially threading unsafe.
        synchronized (this) {

            final HttpContext defaultContext = createHttpContext();
            if (context == null) {
                execContext = defaultContext;
            } else {
                execContext = new DefaultedHttpContext(context, defaultContext);
            }
            // Create a director for this request
            director = createClientRequestDirector(
                    getRequestExecutor(),
                    getConnectionManager(),
                    getConnectionReuseStrategy(),
                    getConnectionKeepAliveStrategy(),
                    getRoutePlanner(),
                    getProtocolProcessor(),
                    getHttpRequestRetryHandler(),
                    getRedirectStrategy(),
                    getTargetAuthenticationStrategy(),
                    getProxyAuthenticationStrategy(),
                    getUserTokenHandler(),
                    determineParams(request));
            routePlanner = getRoutePlanner();
            connectionBackoffStrategy = getConnectionBackoffStrategy();
            backoffManager = getBackoffManager();
        }

        try {
            if (connectionBackoffStrategy != null && backoffManager != null) {
                final HttpHost targetForRoute = (target != null) ? target
                        : (HttpHost) determineParams(request).getParameter(
                                ClientPNames.DEFAULT_HOST);
                final HttpRoute route = routePlanner.determineRoute(targetForRoute, request, execContext);

                CloseableHttpResponse out;
                try {
                    out = CloseableHttpResponseProxy.newProxy(
                            director.execute(target, request, execContext));
View Full Code Here

Examples of org.apache.http.conn.routing.HttpRoutePlanner

            }
            execChain = new RetryExec(execChain, retryHandler);
        }

        // Add redirect executor, if not disabled
        HttpRoutePlanner routePlanner = this.routePlanner;
        if (routePlanner == null) {
            if (proxy != null) {
                routePlanner = new DefaultProxyRoutePlanner(proxy, schemePortResolver);
            } else if (systemProperties) {
                routePlanner = new SystemDefaultRoutePlanner(
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.