use of org.apache.http.conn.routing.HttpRouteDirector in project robolectric by robolectric.
the class DefaultRequestDirector method establishRoute.
/**
* 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
*/
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)
// the hop to establish
final int hop = fact.getHopCount() - 1;
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);
}
use of org.apache.http.conn.routing.HttpRouteDirector in project platform_external_apache-http by android.
the class DefaultRequestDirector method establishRoute.
/**
* 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
*/
protected void establishRoute(HttpRoute route, HttpContext context) throws HttpException, IOException {
//@@@ how to handle CONNECT requests for tunnelling?
//@@@ refuse to send external CONNECT via director? special handling?
//@@@ should the request parameters already be used below?
//@@@ probably yes, but they're not linked yet
//@@@ will linking above cause problems with linking in reqExec?
//@@@ probably not, because the parent is replaced
//@@@ just make sure we don't link parameters to themselves
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)
// the hop to establish
final int hop = fact.getHopCount() - 1;
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);
}
use of org.apache.http.conn.routing.HttpRouteDirector in project XobotOS by xamarin.
the class DefaultRequestDirector method establishRoute.
/**
* 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
*/
protected void establishRoute(HttpRoute route, HttpContext context) throws HttpException, IOException {
//@@@ how to handle CONNECT requests for tunnelling?
//@@@ refuse to send external CONNECT via director? special handling?
//@@@ should the request parameters already be used below?
//@@@ probably yes, but they're not linked yet
//@@@ will linking above cause problems with linking in reqExec?
//@@@ probably not, because the parent is replaced
//@@@ just make sure we don't link parameters to themselves
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)
// the hop to establish
final int hop = fact.getHopCount() - 1;
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);
}
use of org.apache.http.conn.routing.HttpRouteDirector in project robovm by robovm.
the class DefaultRequestDirector method establishRoute.
/**
* 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
*/
protected void establishRoute(HttpRoute route, HttpContext context) throws HttpException, IOException {
//@@@ how to handle CONNECT requests for tunnelling?
//@@@ refuse to send external CONNECT via director? special handling?
//@@@ should the request parameters already be used below?
//@@@ probably yes, but they're not linked yet
//@@@ will linking above cause problems with linking in reqExec?
//@@@ probably not, because the parent is replaced
//@@@ just make sure we don't link parameters to themselves
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)
// the hop to establish
final int hop = fact.getHopCount() - 1;
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);
}
Aggregations