protected int proxiedStep(final RouteInfo plan, final RouteInfo fact) {

        if (fact.getHopCount() <= 1) {
            return UNREACHABLE;
        }
        if (!plan.getTargetHost().equals(fact.getTargetHost())) {
            return UNREACHABLE;
        }
        final int phc = plan.getHopCount();
        final int fhc = fact.getHopCount();
        if (phc < fhc) {
            return UNREACHABLE;
        }

        for (int i = 0; i < fhc - 1; i++) {
            if (!plan.getHopTarget(i).equals(fact.getHopTarget(i))) {
                return UNREACHABLE;
            }
        }
        // now we know that the target matches and proxies so far are the same
        if (phc > fhc)
         {
            return TUNNEL_PROXY; // need to extend the proxy chain
        }

        // proxy chain and target are the same, check tunnelling and layering
        if (fact.isTunnelled() && !plan.isTunnelled() ||
                fact.isLayered() && !plan.isLayered()) {
            return UNREACHABLE;
        }

        if (plan.isTunnelled() && !fact.isTunnelled()) {
            return TUNNEL_TARGET;
        }
        if (plan.isLayered() && !fact.isLayered()) {
            return LAYER_PROTOCOL;
        }

        // tunnel and layering are the same, remains to check the security
        // Should we tolerate if security is better than planned?
        // (plan.isSecure() && !fact.isSecure())
        if (plan.isSecure() != fact.isSecure()) {
            return UNREACHABLE;
        }

        return COMPLETE;
    }
Determines the next step to establish a connection via proxy.

@param plan      the planned route
@param fact      the currently established route

@return  one of the constants defined in this class, indicating
         either the next step to perform, or success, or failure
httpclient5/src/main/java/org/apache/hc/client5/http/impl/routing/BasicRouteDirector.java