shadows/httpclient/src/main/java/org/robolectric/shadows/httpclient/DefaultRequestDirector.java
protected void establishRoute(HttpRoute route, HttpContext context)
    throws HttpException, IOException {

    HttpRouteDirector rowdy = new BasicRouteDirector();
    int step;
    do {
      HttpRoute fact = managedConn.getRoute();
      step = rowdy.nextStep(route, fact);

      switch (step) {

      case HttpRouteDirector.CONNECT_TARGET:
      case HttpRouteDirector.CONNECT_PROXY:
        managedConn.open(route, context, this.params);
        break;

      case HttpRouteDirector.TUNNEL_TARGET: {
        boolean secure = createTunnelToTarget(route, context);
        this.log.debug("Tunnel to target created.");
        managedConn.tunnelTarget(secure, this.params);
      }   break;

      case HttpRouteDirector.TUNNEL_PROXY: {
        // The most simple example for this case is a proxy chain
        // of two proxies, where P1 must be tunnelled to P2.
        // route: Source -> P1 -> P2 -> Target (3 hops)
        // fact:  Source -> P1 -> Target       (2 hops)
        final int hop = fact.getHopCount()-1; // the hop to establish
        boolean secure = createTunnelToProxy(route, hop, context);
        this.log.debug("Tunnel to proxy created.");
        managedConn.tunnelProxy(route.getHopTarget(hop),
                    secure, this.params);
      }   break;


      case HttpRouteDirector.LAYER_PROTOCOL:
        managedConn.layerProtocol(context, this.params);
        break;

      case HttpRouteDirector.UNREACHABLE:
        throw new IllegalStateException
          ("Unable to establish route." +
           "\nplanned = " + route +
           "\ncurrent = " + fact);

      case HttpRouteDirector.COMPLETE:
        // do nothing
        break;

      default:
        throw new IllegalStateException
          ("Unknown step indicator "+step+" from RouteDirector.");
      } // switch

    } while (step > HttpRouteDirector.COMPLETE);

  }
protected void establishRoute(HttpRoute route, HttpContext context)
    throws HttpException, IOException {

    HttpRouteDirector rowdy = new BasicRouteDirector();
    int step;
    do {
      HttpRoute fact = managedConn.getRoute();
      step = rowdy.nextStep(route, fact);

      switch (step) {

      case HttpRouteDirector.CONNECT_TARGET:
      case HttpRouteDirector.CONNECT_PROXY:
        managedConn.open(route, context, this.params);
        break;

      case HttpRouteDirector.TUNNEL_TARGET: {
        boolean secure = createTunnelToTarget(route, context);
        this.log.debug("Tunnel to target created.");
        managedConn.tunnelTarget(secure, this.params);
      }   break;

      case HttpRouteDirector.TUNNEL_PROXY: {
        // The most simple example for this case is a proxy chain
        // of two proxies, where P1 must be tunnelled to P2.
        // route: Source -> P1 -> P2 -> Target (3 hops)
        // fact:  Source -> P1 -> Target       (2 hops)
        final int hop = fact.getHopCount()-1; // the hop to establish
        boolean secure = createTunnelToProxy(route, hop, context);
        this.log.debug("Tunnel to proxy created.");
        managedConn.tunnelProxy(route.getHopTarget(hop),
                    secure, this.params);
      }   break;


      case HttpRouteDirector.LAYER_PROTOCOL:
        managedConn.layerProtocol(context, this.params);
        break;

      case HttpRouteDirector.UNREACHABLE:
        throw new IllegalStateException
          ("Unable to establish route." +
           "\nplanned = " + route +
           "\ncurrent = " + fact);

      case HttpRouteDirector.COMPLETE:
        // do nothing
        break;

      default:
        throw new IllegalStateException
          ("Unknown step indicator "+step+" from RouteDirector.");
      } // switch

    } while (step > HttpRouteDirector.COMPLETE);

  }
protected void establishRoute ( HttpRoute route , HttpContext context ) throws HttpException , IOException { HttpRouteDirector rowdy = new BasicRouteDirector ( ) ; int step ; do { HttpRoute fact = managedConn . getRoute ( ) ; step = rowdy . nextStep ( route , fact ) ; switch ( step ) { case HttpRouteDirector . CONNECT_TARGET : case HttpRouteDirector . CONNECT_PROXY : managedConn . open ( route , context , this . params ) ; break ; case HttpRouteDirector . TUNNEL_TARGET : { boolean secure = createTunnelToTarget ( route , context ) ; this . log . debug ( "Tunnel to target created." ) ; managedConn . tunnelTarget ( secure , this . params ) ; } break ; case HttpRouteDirector . TUNNEL_PROXY : { // The most simple example for this case is a proxy chain // of two proxies, where P1 must be tunnelled to P2. // route: Source -> P1 -> P2 -> Target (3 hops) // fact:  Source -> P1 -> Target       (2 hops) final int hop = fact . getHopCount ( ) - 1 ; // the hop to establish boolean secure = createTunnelToProxy ( route , hop , context ) ; this . log . debug ( "Tunnel to proxy created." ) ; managedConn . tunnelProxy ( route . getHopTarget ( hop ) , secure , this . params ) ; } break ; case HttpRouteDirector . LAYER_PROTOCOL : managedConn . layerProtocol ( context , this . params ) ; break ; case HttpRouteDirector . UNREACHABLE : throw new IllegalStateException ( "Unable to establish route." + "\nplanned = " + route + "\ncurrent = " + fact ) ; case HttpRouteDirector . COMPLETE : // do nothing break ; default : throw new IllegalStateException ( "Unknown step indicator " + step + " from RouteDirector." ) ; } // switch } while ( step > HttpRouteDirector . COMPLETE ) ; }
Establishes the target route.

@param route     the route to establish
@param context   the context for the request execution

@throws HttpException    in case of a problem
@throws IOException      in case of an IO problem
Establishes the target route .