/** * Determines the first step to establish a route. * * @param plan the planned route * * @return the first step */ protected int firstStep(RouteInfo plan) { return (plan.getHopCount() > 1) ? CONNECT_PROXY : CONNECT_TARGET; }
/** * Provides the next step. * * @param plan the planned route * @param fact the currently established route, or * <code>null</code> if nothing is established * * @return one of the constants defined in this class, indicating * either the next step to perform, or success, or failure. * 0 is for success, a negative value for failure. */ public int nextStep(RouteInfo plan, RouteInfo fact) { if (plan == null) { throw new IllegalArgumentException ("Planned route may not be null."); } int step = UNREACHABLE; if ((fact == null) || (fact.getHopCount() < 1)) step = firstStep(plan); else if (plan.getHopCount() > 1) step = proxiedStep(plan, fact); else step = directStep(plan, fact); return step; } // nextStep
/** * Determines the next step to establish a direct connection. * * @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 */ protected int directStep(RouteInfo plan, RouteInfo fact) { if (fact.getHopCount() > 1) return UNREACHABLE; if (!plan.getTargetHost().equals(fact.getTargetHost())) return UNREACHABLE; // If the security is too low, we could now suggest to layer // a secure protocol on the direct connection. Layering on direct // connections has not been supported in HttpClient 3.x, we don't // consider it here until there is a real-life use case for it. // Should we tolerate if security is better than planned? // (plan.isSecure() && !fact.isSecure()) if (plan.isSecure() != fact.isSecure()) return UNREACHABLE; // Local address has to match only if the plan specifies one. if ((plan.getLocalAddress() != null) && !plan.getLocalAddress().equals(fact.getLocalAddress()) ) return UNREACHABLE; return COMPLETE; }
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;
/** * Determines the first step to establish a route. * * @param plan the planned route * * @return the first step */ protected int firstStep(final RouteInfo plan) { return (plan.getHopCount() > 1) ? CONNECT_PROXY : CONNECT_TARGET; }
/** * Determines the first step to establish a route. * * @param plan the planned route * * @return the first step */ protected int firstStep(RouteInfo plan) { return (plan.getHopCount() > 1) ? CONNECT_PROXY : CONNECT_TARGET; }
/** * Determines the first step to establish a route. * * @param plan the planned route * * @return the first step */ protected int firstStep(RouteInfo plan) { return (plan.getHopCount() > 1) ? CONNECT_PROXY : CONNECT_TARGET; }
/** * Determines the first step to establish a route. * * @param plan the planned route * * @return the first step */ protected int firstStep(final RouteInfo plan) { return (plan.getHopCount() > 1) ? CONNECT_PROXY : CONNECT_TARGET; }
/** * Determines the first step to establish a route. * * @param plan the planned route * * @return the first step */ protected int firstStep(final RouteInfo plan) { return (plan.getHopCount() > 1) ? CONNECT_PROXY : CONNECT_TARGET; }
/** * Determines the first step to establish a route. * * @param plan the planned route * * @return the first step */ protected int firstStep(final RouteInfo plan) { return (plan.getHopCount() > 1) ? CONNECT_PROXY : CONNECT_TARGET; }
/** * Determines the first step to establish a route. * * @param plan the planned route * * @return the first step */ protected int firstStep(RouteInfo plan) { return (plan.getHopCount() > 1) ? CONNECT_PROXY : CONNECT_TARGET; }
/** * Determines the first step to establish a route. * * @param plan the planned route * * @return the first step */ protected int firstStep(final RouteInfo plan) { return (plan.getHopCount() > 1) ? CONNECT_PROXY : CONNECT_TARGET; }
/** * Determines the first step to establish a route. * * @param plan the planned route * * @return the first step */ protected int firstStep(final RouteInfo plan) { return (plan.getHopCount() > 1) ? CONNECT_PROXY : CONNECT_TARGET; }
/** * Determines the first step to establish a route. * * @param plan the planned route * * @return the first step */ protected int firstStep(RouteInfo plan) { return (plan.getHopCount() > 1) ? CONNECT_PROXY : CONNECT_TARGET; }
/** * Provides the next step. * * @param plan the planned route * @param fact the currently established route, or * <code>null</code> if nothing is established * * @return one of the constants defined in this class, indicating * either the next step to perform, or success, or failure. * 0 is for success, a negative value for failure. */ public int nextStep(RouteInfo plan, RouteInfo fact) { if (plan == null) { throw new IllegalArgumentException ("Planned route may not be null."); } int step = UNREACHABLE; if ((fact == null) || (fact.getHopCount() < 1)) step = firstStep(plan); else if (plan.getHopCount() > 1) step = proxiedStep(plan, fact); else step = directStep(plan, fact); return step; } // nextStep
/** * Provides the next step. * * @param plan the planned route * @param fact the currently established route, or * {@code null} if nothing is established * * @return one of the constants defined in this class, indicating * either the next step to perform, or success, or failure. * 0 is for success, a negative value for failure. */ @Override public int nextStep(final RouteInfo plan, final RouteInfo fact) { Args.notNull(plan, "Planned route"); int step = UNREACHABLE; if ((fact == null) || (fact.getHopCount() < 1)) { step = firstStep(plan); } else if (plan.getHopCount() > 1) { step = proxiedStep(plan, fact); } else { step = directStep(plan, fact); } return step; } // nextStep
/** * Provides the next step. * * @param plan the planned route * @param fact the currently established route, or * {@code null} if nothing is established * * @return one of the constants defined in this class, indicating * either the next step to perform, or success, or failure. * 0 is for success, a negative value for failure. */ @Override public int nextStep(final RouteInfo plan, final RouteInfo fact) { Args.notNull(plan, "Planned route"); int step = UNREACHABLE; if ((fact == null) || (fact.getHopCount() < 1)) { step = firstStep(plan); } else if (plan.getHopCount() > 1) { step = proxiedStep(plan, fact); } else { step = directStep(plan, fact); } return step; } // nextStep
/** * Provides the next step. * * @param plan the planned route * @param fact the currently established route, or * {@code null} if nothing is established * * @return one of the constants defined in this class, indicating * either the next step to perform, or success, or failure. * 0 is for success, a negative value for failure. */ @Override public int nextStep(final RouteInfo plan, final RouteInfo fact) { Args.notNull(plan, "Planned route"); int step = UNREACHABLE; if ((fact == null) || (fact.getHopCount() < 1)) { step = firstStep(plan); } else if (plan.getHopCount() > 1) { step = proxiedStep(plan, fact); } else { step = directStep(plan, fact); } return step; } // nextStep
/** * Provides the next step. * * @param plan the planned route * @param fact the currently established route, or * <code>null</code> if nothing is established * * @return one of the constants defined in this class, indicating * either the next step to perform, or success, or failure. * 0 is for success, a negative value for failure. */ public int nextStep(final RouteInfo plan, final RouteInfo fact) { Args.notNull(plan, "Planned route"); int step = UNREACHABLE; if ((fact == null) || (fact.getHopCount() < 1)) { step = firstStep(plan); } else if (plan.getHopCount() > 1) { step = proxiedStep(plan, fact); } else { step = directStep(plan, fact); } return step; } // nextStep
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { Args.notNull(request, "HTTP request"); final String method = request.getRequestLine().getMethod(); if (method.equalsIgnoreCase("CONNECT")) { request.setHeader(PROXY_CONN_DIRECTIVE, HTTP.CONN_KEEP_ALIVE); return; } final HttpClientContext clientContext = HttpClientContext.adapt(context); // Obtain the client connection (required) final RouteInfo route = clientContext.getHttpRoute(); if (route == null) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Connection route not set in the context"); } return; } if (route.getHopCount() == 1 || route.isTunnelled()) { if (!request.containsHeader(HTTP.CONN_DIRECTIVE)) { request.addHeader(HTTP.CONN_DIRECTIVE, HTTP.CONN_KEEP_ALIVE); } } if (route.getHopCount() == 2 && !route.isTunnelled()) { if (!request.containsHeader(PROXY_CONN_DIRECTIVE)) { request.addHeader(PROXY_CONN_DIRECTIVE, HTTP.CONN_KEEP_ALIVE); } } }