Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
michael@0 | 1 | /* |
michael@0 | 2 | * ==================================================================== |
michael@0 | 3 | * Licensed to the Apache Software Foundation (ASF) under one |
michael@0 | 4 | * or more contributor license agreements. See the NOTICE file |
michael@0 | 5 | * distributed with this work for additional information |
michael@0 | 6 | * regarding copyright ownership. The ASF licenses this file |
michael@0 | 7 | * to you under the Apache License, Version 2.0 (the |
michael@0 | 8 | * "License"); you may not use this file except in compliance |
michael@0 | 9 | * with the License. You may obtain a copy of the License at |
michael@0 | 10 | * |
michael@0 | 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
michael@0 | 12 | * |
michael@0 | 13 | * Unless required by applicable law or agreed to in writing, |
michael@0 | 14 | * software distributed under the License is distributed on an |
michael@0 | 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
michael@0 | 16 | * KIND, either express or implied. See the License for the |
michael@0 | 17 | * specific language governing permissions and limitations |
michael@0 | 18 | * under the License. |
michael@0 | 19 | * ==================================================================== |
michael@0 | 20 | * |
michael@0 | 21 | * This software consists of voluntary contributions made by many |
michael@0 | 22 | * individuals on behalf of the Apache Software Foundation. For more |
michael@0 | 23 | * information on the Apache Software Foundation, please see |
michael@0 | 24 | * <http://www.apache.org/>. |
michael@0 | 25 | * |
michael@0 | 26 | */ |
michael@0 | 27 | |
michael@0 | 28 | package ch.boye.httpclientandroidlib.conn; |
michael@0 | 29 | |
michael@0 | 30 | import java.io.IOException; |
michael@0 | 31 | import java.net.Socket; |
michael@0 | 32 | |
michael@0 | 33 | import ch.boye.httpclientandroidlib.HttpClientConnection; |
michael@0 | 34 | import ch.boye.httpclientandroidlib.HttpHost; |
michael@0 | 35 | import ch.boye.httpclientandroidlib.HttpInetConnection; |
michael@0 | 36 | import ch.boye.httpclientandroidlib.params.HttpParams; |
michael@0 | 37 | |
michael@0 | 38 | /** |
michael@0 | 39 | * A client-side connection that relies on outside logic to connect sockets to the |
michael@0 | 40 | * appropriate hosts. It can be operated directly by an application, or through an |
michael@0 | 41 | * {@link ClientConnectionOperator operator}. |
michael@0 | 42 | * |
michael@0 | 43 | * @since 4.0 |
michael@0 | 44 | */ |
michael@0 | 45 | public interface OperatedClientConnection extends HttpClientConnection, HttpInetConnection { |
michael@0 | 46 | |
michael@0 | 47 | /** |
michael@0 | 48 | * Obtains the target host for this connection. |
michael@0 | 49 | * If the connection is to a proxy but not tunnelled, this is |
michael@0 | 50 | * the proxy. If the connection is tunnelled through a proxy, |
michael@0 | 51 | * this is the target of the tunnel. |
michael@0 | 52 | * <br/> |
michael@0 | 53 | * The return value is well-defined only while the connection is open. |
michael@0 | 54 | * It may change even while the connection is open, |
michael@0 | 55 | * because of an {@link #update update}. |
michael@0 | 56 | * |
michael@0 | 57 | * @return the host to which this connection is opened |
michael@0 | 58 | */ |
michael@0 | 59 | HttpHost getTargetHost(); |
michael@0 | 60 | |
michael@0 | 61 | /** |
michael@0 | 62 | * Indicates whether this connection is secure. |
michael@0 | 63 | * The return value is well-defined only while the connection is open. |
michael@0 | 64 | * It may change even while the connection is open, |
michael@0 | 65 | * because of an {@link #update update}. |
michael@0 | 66 | * |
michael@0 | 67 | * @return <code>true</code> if this connection is secure, |
michael@0 | 68 | * <code>false</code> otherwise |
michael@0 | 69 | */ |
michael@0 | 70 | boolean isSecure(); |
michael@0 | 71 | |
michael@0 | 72 | /** |
michael@0 | 73 | * Obtains the socket for this connection. |
michael@0 | 74 | * The return value is well-defined only while the connection is open. |
michael@0 | 75 | * It may change even while the connection is open, |
michael@0 | 76 | * because of an {@link #update update}. |
michael@0 | 77 | * |
michael@0 | 78 | * @return the socket for communicating with the |
michael@0 | 79 | * {@link #getTargetHost target host} |
michael@0 | 80 | */ |
michael@0 | 81 | Socket getSocket(); |
michael@0 | 82 | |
michael@0 | 83 | /** |
michael@0 | 84 | * Signals that this connection is in the process of being open. |
michael@0 | 85 | * <p> |
michael@0 | 86 | * By calling this method, the connection can be re-initialized |
michael@0 | 87 | * with a new Socket instance before {@link #openCompleted} is called. |
michael@0 | 88 | * This enabled the connection to close that socket if |
michael@0 | 89 | * {@link ch.boye.httpclientandroidlib.HttpConnection#shutdown shutdown} |
michael@0 | 90 | * is called before it is fully open. Closing an unconnected socket |
michael@0 | 91 | * will interrupt a thread that is blocked on the connect. |
michael@0 | 92 | * Otherwise, that thread will either time out on the connect, |
michael@0 | 93 | * or it returns successfully and then opens this connection |
michael@0 | 94 | * which was just shut down. |
michael@0 | 95 | * <p> |
michael@0 | 96 | * This method can be called multiple times if the connection |
michael@0 | 97 | * is layered over another protocol. <b>Note:</b> This method |
michael@0 | 98 | * will <i>not</i> close the previously used socket. It is |
michael@0 | 99 | * the caller's responsibility to close that socket if it is |
michael@0 | 100 | * no longer required. |
michael@0 | 101 | * <p> |
michael@0 | 102 | * The caller must invoke {@link #openCompleted} in order to complete |
michael@0 | 103 | * the process. |
michael@0 | 104 | * |
michael@0 | 105 | * @param sock the unconnected socket which is about to |
michael@0 | 106 | * be connected. |
michael@0 | 107 | * @param target the target host of this connection |
michael@0 | 108 | */ |
michael@0 | 109 | void opening(Socket sock, HttpHost target) |
michael@0 | 110 | throws IOException; |
michael@0 | 111 | |
michael@0 | 112 | /** |
michael@0 | 113 | * Signals that the connection has been successfully open. |
michael@0 | 114 | * An attempt to call this method on an open connection will cause |
michael@0 | 115 | * an exception. |
michael@0 | 116 | * |
michael@0 | 117 | * @param secure <code>true</code> if this connection is secure, for |
michael@0 | 118 | * example if an <code>SSLSocket</code> is used, or |
michael@0 | 119 | * <code>false</code> if it is not secure |
michael@0 | 120 | * @param params parameters for this connection. The parameters will |
michael@0 | 121 | * be used when creating dependent objects, for example |
michael@0 | 122 | * to determine buffer sizes. |
michael@0 | 123 | */ |
michael@0 | 124 | void openCompleted(boolean secure, HttpParams params) |
michael@0 | 125 | throws IOException; |
michael@0 | 126 | |
michael@0 | 127 | /** |
michael@0 | 128 | * Updates this connection. |
michael@0 | 129 | * A connection can be updated only while it is open. |
michael@0 | 130 | * Updates are used for example when a tunnel has been established, |
michael@0 | 131 | * or when a TLS/SSL connection has been layered on top of a plain |
michael@0 | 132 | * socket connection. |
michael@0 | 133 | * <br/> |
michael@0 | 134 | * <b>Note:</b> Updating the connection will <i>not</i> close the |
michael@0 | 135 | * previously used socket. It is the caller's responsibility to close |
michael@0 | 136 | * that socket if it is no longer required. |
michael@0 | 137 | * |
michael@0 | 138 | * @param sock the new socket for communicating with the target host, |
michael@0 | 139 | * or <code>null</code> to continue using the old socket. |
michael@0 | 140 | * If <code>null</code> is passed, helper objects that |
michael@0 | 141 | * depend on the socket should be re-used. In that case, |
michael@0 | 142 | * some changes in the parameters will not take effect. |
michael@0 | 143 | * @param target the new target host of this connection |
michael@0 | 144 | * @param secure <code>true</code> if this connection is now secure, |
michael@0 | 145 | * <code>false</code> if it is not secure |
michael@0 | 146 | * @param params new parameters for this connection |
michael@0 | 147 | */ |
michael@0 | 148 | void update(Socket sock, HttpHost target, |
michael@0 | 149 | boolean secure, HttpParams params) |
michael@0 | 150 | throws IOException; |
michael@0 | 151 | |
michael@0 | 152 | } |