1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/mobile/android/thirdparty/ch/boye/httpclientandroidlib/conn/routing/RouteInfo.java Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,161 @@ 1.4 +/* 1.5 + * ==================================================================== 1.6 + * Licensed to the Apache Software Foundation (ASF) under one 1.7 + * or more contributor license agreements. See the NOTICE file 1.8 + * distributed with this work for additional information 1.9 + * regarding copyright ownership. The ASF licenses this file 1.10 + * to you under the Apache License, Version 2.0 (the 1.11 + * "License"); you may not use this file except in compliance 1.12 + * with the License. You may obtain a copy of the License at 1.13 + * 1.14 + * http://www.apache.org/licenses/LICENSE-2.0 1.15 + * 1.16 + * Unless required by applicable law or agreed to in writing, 1.17 + * software distributed under the License is distributed on an 1.18 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1.19 + * KIND, either express or implied. See the License for the 1.20 + * specific language governing permissions and limitations 1.21 + * under the License. 1.22 + * ==================================================================== 1.23 + * 1.24 + * This software consists of voluntary contributions made by many 1.25 + * individuals on behalf of the Apache Software Foundation. For more 1.26 + * information on the Apache Software Foundation, please see 1.27 + * <http://www.apache.org/>. 1.28 + * 1.29 + */ 1.30 + 1.31 +package ch.boye.httpclientandroidlib.conn.routing; 1.32 + 1.33 +import java.net.InetAddress; 1.34 + 1.35 +import ch.boye.httpclientandroidlib.HttpHost; 1.36 + 1.37 +/** 1.38 + * Read-only interface for route information. 1.39 + * 1.40 + * @since 4.0 1.41 + */ 1.42 +public interface RouteInfo { 1.43 + 1.44 + /** 1.45 + * The tunnelling type of a route. 1.46 + * Plain routes are established by connecting to the target or 1.47 + * the first proxy. 1.48 + * Tunnelled routes are established by connecting to the first proxy 1.49 + * and tunnelling through all proxies to the target. 1.50 + * Routes without a proxy cannot be tunnelled. 1.51 + */ 1.52 + public enum TunnelType { PLAIN, TUNNELLED } 1.53 + 1.54 + /** 1.55 + * The layering type of a route. 1.56 + * Plain routes are established by connecting or tunnelling. 1.57 + * Layered routes are established by layering a protocol such as TLS/SSL 1.58 + * over an existing connection. 1.59 + * Protocols can only be layered over a tunnel to the target, or 1.60 + * or over a direct connection without proxies. 1.61 + * <br/> 1.62 + * Layering a protocol 1.63 + * over a direct connection makes little sense, since the connection 1.64 + * could be established with the new protocol in the first place. 1.65 + * But we don't want to exclude that use case. 1.66 + */ 1.67 + public enum LayerType { PLAIN, LAYERED } 1.68 + 1.69 + /** 1.70 + * Obtains the target host. 1.71 + * 1.72 + * @return the target host 1.73 + */ 1.74 + HttpHost getTargetHost(); 1.75 + 1.76 + /** 1.77 + * Obtains the local address to connect from. 1.78 + * 1.79 + * @return the local address, 1.80 + * or <code>null</code> 1.81 + */ 1.82 + InetAddress getLocalAddress(); 1.83 + 1.84 + /** 1.85 + * Obtains the number of hops in this route. 1.86 + * A direct route has one hop. A route through a proxy has two hops. 1.87 + * A route through a chain of <i>n</i> proxies has <i>n+1</i> hops. 1.88 + * 1.89 + * @return the number of hops in this route 1.90 + */ 1.91 + int getHopCount(); 1.92 + 1.93 + /** 1.94 + * Obtains the target of a hop in this route. 1.95 + * The target of the last hop is the {@link #getTargetHost target host}, 1.96 + * the target of previous hops is the respective proxy in the chain. 1.97 + * For a route through exactly one proxy, target of hop 0 is the proxy 1.98 + * and target of hop 1 is the target host. 1.99 + * 1.100 + * @param hop index of the hop for which to get the target, 1.101 + * 0 for first 1.102 + * 1.103 + * @return the target of the given hop 1.104 + * 1.105 + * @throws IllegalArgumentException 1.106 + * if the argument is negative or not less than 1.107 + * {@link #getHopCount getHopCount()} 1.108 + */ 1.109 + HttpHost getHopTarget(int hop); 1.110 + 1.111 + /** 1.112 + * Obtains the first proxy host. 1.113 + * 1.114 + * @return the first proxy in the proxy chain, or 1.115 + * <code>null</code> if this route is direct 1.116 + */ 1.117 + HttpHost getProxyHost(); 1.118 + 1.119 + /** 1.120 + * Obtains the tunnel type of this route. 1.121 + * If there is a proxy chain, only end-to-end tunnels are considered. 1.122 + * 1.123 + * @return the tunnelling type 1.124 + */ 1.125 + TunnelType getTunnelType(); 1.126 + 1.127 + /** 1.128 + * Checks whether this route is tunnelled through a proxy. 1.129 + * If there is a proxy chain, only end-to-end tunnels are considered. 1.130 + * 1.131 + * @return <code>true</code> if tunnelled end-to-end through at least 1.132 + * one proxy, 1.133 + * <code>false</code> otherwise 1.134 + */ 1.135 + boolean isTunnelled(); 1.136 + 1.137 + /** 1.138 + * Obtains the layering type of this route. 1.139 + * In the presence of proxies, only layering over an end-to-end tunnel 1.140 + * is considered. 1.141 + * 1.142 + * @return the layering type 1.143 + */ 1.144 + LayerType getLayerType(); 1.145 + 1.146 + /** 1.147 + * Checks whether this route includes a layered protocol. 1.148 + * In the presence of proxies, only layering over an end-to-end tunnel 1.149 + * is considered. 1.150 + * 1.151 + * @return <code>true</code> if layered, 1.152 + * <code>false</code> otherwise 1.153 + */ 1.154 + boolean isLayered(); 1.155 + 1.156 + /** 1.157 + * Checks whether this route is secure. 1.158 + * 1.159 + * @return <code>true</code> if secure, 1.160 + * <code>false</code> otherwise 1.161 + */ 1.162 + boolean isSecure(); 1.163 + 1.164 +}