1069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project/*
2069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/OperatedClientConnection.java $
3069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * $Revision: 646087 $
4069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * $Date: 2008-04-08 14:36:46 -0700 (Tue, 08 Apr 2008) $
5069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project *
6069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * ====================================================================
7069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * Licensed to the Apache Software Foundation (ASF) under one
8069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * or more contributor license agreements.  See the NOTICE file
9069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * distributed with this work for additional information
10069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * regarding copyright ownership.  The ASF licenses this file
11069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * to you under the Apache License, Version 2.0 (the
12069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * "License"); you may not use this file except in compliance
13069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * with the License.  You may obtain a copy of the License at
14069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project *
15069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project *   http://www.apache.org/licenses/LICENSE-2.0
16069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project *
17069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * Unless required by applicable law or agreed to in writing,
18069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * software distributed under the License is distributed on an
19069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * KIND, either express or implied.  See the License for the
21069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * specific language governing permissions and limitations
22069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * under the License.
23069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * ====================================================================
24069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project *
25069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * This software consists of voluntary contributions made by many
26069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * individuals on behalf of the Apache Software Foundation.  For more
27069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * information on the Apache Software Foundation, please see
28069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * <http://www.apache.org/>.
29069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project *
30069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project */
31069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
32069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Projectpackage org.apache.http.conn;
33069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
34069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Projectimport java.io.IOException;
35069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Projectimport java.net.Socket;
36069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
37069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Projectimport org.apache.http.HttpClientConnection;
38069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Projectimport org.apache.http.HttpHost;
39069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Projectimport org.apache.http.HttpInetConnection;
40069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Projectimport org.apache.http.params.HttpParams;
41069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
42069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
43069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project/**
44069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * A client-side connection that relies on outside logic to connect sockets to the
45069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * appropriate hosts. It can be operated directly by an application, or through an
46069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * {@link ClientConnectionOperator operator}.
47069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project *
48069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project *
49069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * @author <a href="mailto:rolandw at apache.org">Roland Weber</a>
50069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project *
51069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project *
52069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * <!-- empty lines to avoid svn diff problems -->
53069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * @version   $Revision: 646087 $ $Date: 2008-04-08 14:36:46 -0700 (Tue, 08 Apr 2008) $
54069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project *
55069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * @since 4.0
56d42abb2fd917184764daf22f5f299e848b8701d7Narayan Kamath *
57d42abb2fd917184764daf22f5f299e848b8701d7Narayan Kamath * @deprecated Please use {@link java.net.URL#openConnection} instead.
58d42abb2fd917184764daf22f5f299e848b8701d7Narayan Kamath *     Please visit <a href="http://android-developers.blogspot.com/2011/09/androids-http-clients.html">this webpage</a>
59d42abb2fd917184764daf22f5f299e848b8701d7Narayan Kamath *     for further details.
60069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project */
61d42abb2fd917184764daf22f5f299e848b8701d7Narayan Kamath@Deprecated
62069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Projectpublic interface OperatedClientConnection
63069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    extends HttpClientConnection, HttpInetConnection {
64069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
65069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    /**
66069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Obtains the target host for this connection.
67069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * If the connection is to a proxy but not tunnelled, this is
68069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * the proxy. If the connection is tunnelled through a proxy,
69069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * this is the target of the tunnel.
70069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * <br/>
71069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * The return value is well-defined only while the connection is open.
72069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * It may change even while the connection is open,
73069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * because of an {@link #update update}.
74069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *
75069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @return  the host to which this connection is opened
76069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     */
77069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    HttpHost getTargetHost()
78069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        ;
79069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
80069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    /**
81069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Indicates whether this connection is secure.
82069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * The return value is well-defined only while the connection is open.
83069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * It may change even while the connection is open,
84069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * because of an {@link #update update}.
85069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *
86069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @return  <code>true</code> if this connection is secure,
87069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *          <code>false</code> otherwise
88069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     */
89069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    boolean isSecure()
90069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        ;
91069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
92069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    /**
93069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Obtains the socket for this connection.
94069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * The return value is well-defined only while the connection is open.
95069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * It may change even while the connection is open,
96069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * because of an {@link #update update}.
97069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *
98069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @return  the socket for communicating with the
99069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *          {@link #getTargetHost target host}
100069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     */
101069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    Socket getSocket()
102069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        ;
103069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
104069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
105069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    // There is no getParams(). For the moment, we
106069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    // do not require connections to store parameters.
107069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
108069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
109069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    /**
110069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Signals that this connection is in the process of being open.
111069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * <br/>
112069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * By calling this method, you can provide the connection with
113069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * the unconnected socket that will be connected before
114069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * {@link #openCompleted} is called. This allows
115069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * the connection to close that socket if
116069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * {@link org.apache.http.HttpConnection#shutdown shutdown}
117069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * is called before it is open. Closing the unconnected socket
118069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * will interrupt a thread that is blocked on the connect.
119069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Otherwise, that thread will either time out on the connect,
120069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * or it returns successfully and then opens this connection
121069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * which was just shut down.
122069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * <br/>
123069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * You also must call {@link #openCompleted} in order to complete
124069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * the process
125069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *
126069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @param sock      the unconnected socket which is about to
127069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *                  be connected.
128069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @param target    the target host of this connection
129069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     */
130069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    void opening(Socket sock, HttpHost target)
131069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        throws IOException
132069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        ;
133069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
134069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
135069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    /**
136069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Signals that the connection has been successfully open.
137069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * An attempt to call this method on an open connection will cause
138069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * an exception.
139069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *
140069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @param secure    <code>true</code> if this connection is secure, for
141069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *                  example if an <code>SSLSocket</code> is used, or
142069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *                  <code>false</code> if it is not secure
143069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @param params    parameters for this connection. The parameters will
144069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *                  be used when creating dependent objects, for example
145069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *                  to determine buffer sizes.
146069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     */
147069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    void openCompleted(boolean secure, HttpParams params)
148069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        throws IOException
149069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        ;
150069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
151069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
152069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    /**
153069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Updates this connection.
154069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * A connection can be updated only while it is open.
155069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Updates are used for example when a tunnel has been established,
156069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * or when a TLS/SSL connection has been layered on top of a plain
157069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * socket connection.
158069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * <br/>
159069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * <b>Note:</b> Updating the connection will <i>not</i> close the
160069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * previously used socket. It is the caller's responsibility to close
161069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * that socket if it is no longer required.
162069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *
163069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @param sock      the new socket for communicating with the target host,
164069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *                  or <code>null</code> to continue using the old socket.
165069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *                  If <code>null</code> is passed, helper objects that
166069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *                  depend on the socket should be re-used. In that case,
167069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *                  some changes in the parameters will not take effect.
168069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @param target    the new target host of this connection
169069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @param secure    <code>true</code> if this connection is now secure,
170069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *                  <code>false</code> if it is not secure
171069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @param params    new parameters for this connection
172069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     */
173069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    void update(Socket sock, HttpHost target,
174069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project                boolean secure, HttpParams params)
175069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        throws IOException
176069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        ;
177069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
178069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
179069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project} // interface OperatedClientConnection
180