FileDocCategorySizeDatePackage
DefaultHttpRoutePlanner.javaAPI DocAndroid 1.5 API4166Wed May 06 22:41:10 BST 2009org.apache.http.impl.conn

DefaultHttpRoutePlanner

public class DefaultHttpRoutePlanner extends Object implements HttpRoutePlanner
Default implementation of an {@link HttpRoutePlanner}. This implementation is based on {@link org.apache.http.conn.params.ConnRoutePNames parameters}. It will not make use of any Java system properties, nor of system or browser proxy settings.

Fields Summary
protected SchemeRegistry
schemeRegistry
The scheme registry.
Constructors Summary
public DefaultHttpRoutePlanner(SchemeRegistry schreg)
Creates a new default route planner.

param
schreg the scheme registry

        if (schreg == null) {
            throw new IllegalArgumentException
                ("SchemeRegistry must not be null.");
        }
        schemeRegistry = schreg;
    
Methods Summary
public org.apache.http.conn.routing.HttpRoutedetermineRoute(org.apache.http.HttpHost target, org.apache.http.HttpRequest request, org.apache.http.protocol.HttpContext context)


        if (request == null) {
            throw new IllegalStateException
                ("Request must not be null.");
        }

        // If we have a forced route, we can do without a target.
        HttpRoute route =
            ConnRouteParams.getForcedRoute(request.getParams());
        if (route != null)
            return route;

        // If we get here, there is no forced route.
        // So we need a target to compute a route.

        if (target == null) {
            throw new IllegalStateException
                ("Target host must not be null.");
        }

        final InetAddress local =
            ConnRouteParams.getLocalAddress(request.getParams());
        final HttpHost proxy =
            ConnRouteParams.getDefaultProxy(request.getParams());

        final Scheme schm = schemeRegistry.getScheme(target.getSchemeName());
        // as it is typically used for TLS/SSL, we assume that
        // a layered scheme implies a secure connection
        final boolean secure = schm.isLayered();

        if (proxy == null) {
            route = new HttpRoute(target, local, secure);
        } else {
            route = new HttpRoute(target, local, proxy, secure);
        }
        return route;