mobile/android/thirdparty/ch/boye/httpclientandroidlib/conn/OperatedClientConnection.java

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mobile/android/thirdparty/ch/boye/httpclientandroidlib/conn/OperatedClientConnection.java	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,152 @@
     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;
    1.32 +
    1.33 +import java.io.IOException;
    1.34 +import java.net.Socket;
    1.35 +
    1.36 +import ch.boye.httpclientandroidlib.HttpClientConnection;
    1.37 +import ch.boye.httpclientandroidlib.HttpHost;
    1.38 +import ch.boye.httpclientandroidlib.HttpInetConnection;
    1.39 +import ch.boye.httpclientandroidlib.params.HttpParams;
    1.40 +
    1.41 +/**
    1.42 + * A client-side connection that relies on outside logic to connect sockets to the
    1.43 + * appropriate hosts. It can be operated directly by an application, or through an
    1.44 + * {@link ClientConnectionOperator operator}.
    1.45 + *
    1.46 + * @since 4.0
    1.47 + */
    1.48 +public interface OperatedClientConnection extends HttpClientConnection, HttpInetConnection {
    1.49 +
    1.50 +    /**
    1.51 +     * Obtains the target host for this connection.
    1.52 +     * If the connection is to a proxy but not tunnelled, this is
    1.53 +     * the proxy. If the connection is tunnelled through a proxy,
    1.54 +     * this is the target of the tunnel.
    1.55 +     * <br/>
    1.56 +     * The return value is well-defined only while the connection is open.
    1.57 +     * It may change even while the connection is open,
    1.58 +     * because of an {@link #update update}.
    1.59 +     *
    1.60 +     * @return  the host to which this connection is opened
    1.61 +     */
    1.62 +    HttpHost getTargetHost();
    1.63 +
    1.64 +    /**
    1.65 +     * Indicates whether this connection is secure.
    1.66 +     * The return value is well-defined only while the connection is open.
    1.67 +     * It may change even while the connection is open,
    1.68 +     * because of an {@link #update update}.
    1.69 +     *
    1.70 +     * @return  <code>true</code> if this connection is secure,
    1.71 +     *          <code>false</code> otherwise
    1.72 +     */
    1.73 +    boolean isSecure();
    1.74 +
    1.75 +    /**
    1.76 +     * Obtains the socket for this connection.
    1.77 +     * The return value is well-defined only while the connection is open.
    1.78 +     * It may change even while the connection is open,
    1.79 +     * because of an {@link #update update}.
    1.80 +     *
    1.81 +     * @return  the socket for communicating with the
    1.82 +     *          {@link #getTargetHost target host}
    1.83 +     */
    1.84 +    Socket getSocket();
    1.85 +
    1.86 +    /**
    1.87 +     * Signals that this connection is in the process of being open.
    1.88 +     * <p>
    1.89 +     * By calling this method, the connection can be re-initialized
    1.90 +     * with a new Socket instance before {@link #openCompleted} is called.
    1.91 +     * This enabled the connection to close that socket if
    1.92 +     * {@link ch.boye.httpclientandroidlib.HttpConnection#shutdown shutdown}
    1.93 +     * is called before it is fully open. Closing an unconnected socket
    1.94 +     * will interrupt a thread that is blocked on the connect.
    1.95 +     * Otherwise, that thread will either time out on the connect,
    1.96 +     * or it returns successfully and then opens this connection
    1.97 +     * which was just shut down.
    1.98 +     * <p>
    1.99 +     * This method can be called multiple times if the connection
   1.100 +     * is layered over another protocol. <b>Note:</b> This method
   1.101 +     * will <i>not</i> close the previously used socket. It is
   1.102 +     * the caller's responsibility to close that socket if it is
   1.103 +     * no longer required.
   1.104 +     * <p>
   1.105 +     * The caller must invoke {@link #openCompleted} in order to complete
   1.106 +     * the process.
   1.107 +     *
   1.108 +     * @param sock      the unconnected socket which is about to
   1.109 +     *                  be connected.
   1.110 +     * @param target    the target host of this connection
   1.111 +     */
   1.112 +    void opening(Socket sock, HttpHost target)
   1.113 +        throws IOException;
   1.114 +
   1.115 +    /**
   1.116 +     * Signals that the connection has been successfully open.
   1.117 +     * An attempt to call this method on an open connection will cause
   1.118 +     * an exception.
   1.119 +     *
   1.120 +     * @param secure    <code>true</code> if this connection is secure, for
   1.121 +     *                  example if an <code>SSLSocket</code> is used, or
   1.122 +     *                  <code>false</code> if it is not secure
   1.123 +     * @param params    parameters for this connection. The parameters will
   1.124 +     *                  be used when creating dependent objects, for example
   1.125 +     *                  to determine buffer sizes.
   1.126 +     */
   1.127 +    void openCompleted(boolean secure, HttpParams params)
   1.128 +        throws IOException;
   1.129 +
   1.130 +    /**
   1.131 +     * Updates this connection.
   1.132 +     * A connection can be updated only while it is open.
   1.133 +     * Updates are used for example when a tunnel has been established,
   1.134 +     * or when a TLS/SSL connection has been layered on top of a plain
   1.135 +     * socket connection.
   1.136 +     * <br/>
   1.137 +     * <b>Note:</b> Updating the connection will <i>not</i> close the
   1.138 +     * previously used socket. It is the caller's responsibility to close
   1.139 +     * that socket if it is no longer required.
   1.140 +     *
   1.141 +     * @param sock      the new socket for communicating with the target host,
   1.142 +     *                  or <code>null</code> to continue using the old socket.
   1.143 +     *                  If <code>null</code> is passed, helper objects that
   1.144 +     *                  depend on the socket should be re-used. In that case,
   1.145 +     *                  some changes in the parameters will not take effect.
   1.146 +     * @param target    the new target host of this connection
   1.147 +     * @param secure    <code>true</code> if this connection is now secure,
   1.148 +     *                  <code>false</code> if it is not secure
   1.149 +     * @param params    new parameters for this connection
   1.150 +     */
   1.151 +    void update(Socket sock, HttpHost target,
   1.152 +                boolean secure, HttpParams params)
   1.153 +        throws IOException;
   1.154 +
   1.155 +}

mercurial