Package org.apache.http.conn.routing

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


            final HttpRoute route,
            final HttpRequest request,
            final HttpClientContext context) throws HttpException, IOException {
        final RequestConfig config = context.getRequestConfig();
        final int timeout = config.getConnectTimeout();
        final RouteTracker tracker = new RouteTracker(route);
        int step;
        do {
            final HttpRoute fact = tracker.toRoute();
            step = this.routeDirector.nextStep(route, fact);

            switch (step) {

            case HttpRouteDirector.CONNECT_TARGET:
                this.connManager.connect(
                        managedConn,
                        route,
                        timeout > 0 ? timeout : 0,
                        context);
                tracker.connectTarget(route.isSecure());
                break;
            case HttpRouteDirector.CONNECT_PROXY:
                this.connManager.connect(
                        managedConn,
                        route,
                        timeout > 0 ? timeout : 0,
                        context);
                final HttpHost proxy  = route.getProxyHost();
                tracker.connectProxy(proxy, false);
                break;
            case HttpRouteDirector.TUNNEL_TARGET: {
                final boolean secure = createTunnelToTarget(
                        proxyAuthState, managedConn, route, request, context);
                this.log.debug("Tunnel to target created.");
                tracker.tunnelTarget(secure);
            }   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
                final boolean secure = createTunnelToProxy(route, hop, context);
                this.log.debug("Tunnel to proxy created.");
                tracker.tunnelProxy(route.getHopTarget(hop), secure);
            }   break;

            case HttpRouteDirector.LAYER_PROTOCOL:
                this.connManager.upgrade(managedConn, route, context);
                tracker.layerProtocol(route.isSecure());
                break;

            case HttpRouteDirector.UNREACHABLE:
                throw new HttpException("Unable to establish route: " +
                        "planned = " + route + "; current = " + fact);
View Full Code Here


  public void tunnelTarget(boolean paramBoolean, HttpParams paramHttpParams)
    throws IOException
  {
    if (paramHttpParams == null)
      throw new IllegalArgumentException("HTTP parameters may not be null");
    RouteTracker localRouteTracker;
    HttpHost localHttpHost;
    OperatedClientConnection localOperatedClientConnection;
    synchronized (this)
    {
      if (this.poolEntry == null)
        throw new ConnectionShutdownException();
      localRouteTracker = this.poolEntry.getTracker();
      if (!localRouteTracker.isConnected())
        throw new IllegalStateException("Connection not open");
      if (localRouteTracker.isTunnelled())
        throw new IllegalStateException("Connection is already tunnelled");
      localHttpHost = localRouteTracker.getTargetHost();
      localOperatedClientConnection = (OperatedClientConnection)this.poolEntry.getConnection();
    }
    localOperatedClientConnection.update(null, localHttpHost, paramBoolean, paramHttpParams);
    synchronized (this)
    {
      if (this.poolEntry == null)
        throw new InterruptedIOException();
      localRouteTracker = this.poolEntry.getTracker();
      localRouteTracker.tunnelTarget(paramBoolean);
    }
  }
View Full Code Here

  {
    if (paramHttpHost == null)
      throw new IllegalArgumentException("Next proxy amy not be null");
    if (paramHttpParams == null)
      throw new IllegalArgumentException("HTTP parameters may not be null");
    RouteTracker localRouteTracker;
    OperatedClientConnection localOperatedClientConnection;
    synchronized (this)
    {
      if (this.poolEntry == null)
        throw new ConnectionShutdownException();
      localRouteTracker = this.poolEntry.getTracker();
      if (!localRouteTracker.isConnected())
        throw new IllegalStateException("Connection not open");
      localOperatedClientConnection = (OperatedClientConnection)this.poolEntry.getConnection();
    }
    localOperatedClientConnection.update(null, paramHttpHost, paramBoolean, paramHttpParams);
    synchronized (this)
    {
      if (this.poolEntry == null)
        throw new InterruptedIOException();
      localRouteTracker = this.poolEntry.getTracker();
      localRouteTracker.tunnelProxy(paramHttpHost, paramBoolean);
    }
  }
View Full Code Here

  public void layerProtocol(HttpContext paramHttpContext, HttpParams paramHttpParams)
    throws IOException
  {
    if (paramHttpParams == null)
      throw new IllegalArgumentException("HTTP parameters may not be null");
    RouteTracker localRouteTracker;
    HttpHost localHttpHost;
    OperatedClientConnection localOperatedClientConnection;
    synchronized (this)
    {
      if (this.poolEntry == null)
        throw new ConnectionShutdownException();
      localRouteTracker = this.poolEntry.getTracker();
      if (!localRouteTracker.isConnected())
        throw new IllegalStateException("Connection not open");
      if (!localRouteTracker.isTunnelled())
        throw new IllegalStateException("Protocol layering without a tunnel not supported");
      if (localRouteTracker.isLayered())
        throw new IllegalStateException("Multiple protocol layering not supported");
      localHttpHost = localRouteTracker.getTargetHost();
      localOperatedClientConnection = (OperatedClientConnection)this.poolEntry.getConnection();
    }
    this.operator.updateSecureConnection(localOperatedClientConnection, localHttpHost, paramHttpContext, paramHttpParams);
    synchronized (this)
    {
      if (this.poolEntry == null)
        throw new InterruptedIOException();
      localRouteTracker = this.poolEntry.getTracker();
      localRouteTracker.layerProtocol(localOperatedClientConnection.isSecure());
    }
  }
View Full Code Here

  public HttpPoolEntry(Log paramLog, String paramString, HttpRoute paramHttpRoute, OperatedClientConnection paramOperatedClientConnection, long paramLong, TimeUnit paramTimeUnit)
  {
    super(paramString, paramHttpRoute, paramOperatedClientConnection, paramLong, paramTimeUnit);
    this.log = paramLog;
    this.tracker = new RouteTracker(paramHttpRoute);
  }
View Full Code Here

        // In this order, we can be sure that only a successful
        // opening of the connection will be tracked.

        //@@@ verify route against planned route?

        this.tracker = new RouteTracker(route);
        final HttpHost proxy  = route.getProxyHost();

        connOperator.openConnection
            (this.connection,
             (proxy != null) ? proxy : route.getTargetHost(),
View Full Code Here

            final HttpRoute route,
            final HttpRequest request,
            final HttpClientContext context) throws HttpException, IOException {
        final RequestConfig config = context.getRequestConfig();
        final int timeout = config.getConnectTimeout();
        final RouteTracker tracker = new RouteTracker(route);
        int step;
        do {
            final HttpRoute fact = tracker.toRoute();
            step = this.routeDirector.nextStep(route, fact);

            switch (step) {

            case HttpRouteDirector.CONNECT_TARGET:
                this.connManager.connect(
                        managedConn,
                        route,
                        timeout > 0 ? timeout : 0,
                        context);
                tracker.connectTarget(route.isSecure());
                break;
            case HttpRouteDirector.CONNECT_PROXY:
                this.connManager.connect(
                        managedConn,
                        route,
                        timeout > 0 ? timeout : 0,
                        context);
                final HttpHost proxy  = route.getProxyHost();
                tracker.connectProxy(proxy, false);
                break;
            case HttpRouteDirector.TUNNEL_TARGET: {
                final boolean secure = createTunnelToTarget(
                        proxyAuthState, managedConn, route, request, context);
                this.log.debug("Tunnel to target created.");
                tracker.tunnelTarget(secure);
            }   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
                final boolean secure = createTunnelToProxy(route, hop, context);
                this.log.debug("Tunnel to proxy created.");
                tracker.tunnelProxy(route.getHopTarget(hop), secure);
            }   break;

            case HttpRouteDirector.LAYER_PROTOCOL:
                this.connManager.upgrade(managedConn, route, context);
                tracker.layerProtocol(route.isSecure());
                break;

            case HttpRouteDirector.UNREACHABLE:
                throw new HttpException("Unable to establish route: " +
                        "planned = " + route + "; current = " + fact);
View Full Code Here

            final HttpRoute route,
            final HttpRequest request,
            final HttpClientContext context) throws HttpException, IOException {
        final RequestConfig config = context.getRequestConfig();
        final int timeout = config.getConnectTimeout();
        final RouteTracker tracker = new RouteTracker(route);
        int step;
        do {
            final HttpRoute fact = tracker.toRoute();
            step = this.routeDirector.nextStep(route, fact);

            switch (step) {

            case HttpRouteDirector.CONNECT_TARGET:
                this.connManager.connect(
                        managedConn,
                        route,
                        timeout > 0 ? timeout : 0,
                        context);
                tracker.connectTarget(route.isSecure());
                break;
            case HttpRouteDirector.CONNECT_PROXY:
                this.connManager.connect(
                        managedConn,
                        route,
                        timeout > 0 ? timeout : 0,
                        context);
                final HttpHost proxy  = route.getProxyHost();
                tracker.connectProxy(proxy, false);
                break;
            case HttpRouteDirector.TUNNEL_TARGET: {
                final boolean secure = createTunnelToTarget(
                        proxyAuthState, managedConn, route, request, context);
                this.log.debug("Tunnel to target created.");
                tracker.tunnelTarget(secure);
            }   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
                final boolean secure = createTunnelToProxy(route, hop, context);
                this.log.debug("Tunnel to proxy created.");
                tracker.tunnelProxy(route.getHopTarget(hop), secure);
            }   break;

            case HttpRouteDirector.LAYER_PROTOCOL:
                this.connManager.upgrade(managedConn, route, context);
                tracker.layerProtocol(route.isSecure());
                break;

            case HttpRouteDirector.UNREACHABLE:
                throw new HttpException("Unable to establish route: " +
                        "planned = " + route + "; current = " + fact);
View Full Code Here

TOP

Related Classes of org.apache.http.conn.routing.RouteTracker

Copyright © 2018 www.massapicom. 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.