• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/OperatedClientConnection.java $
3  * $Revision: 646087 $
4  * $Date: 2008-04-08 14:36:46 -0700 (Tue, 08 Apr 2008) $
5  *
6  * ====================================================================
7  * Licensed to the Apache Software Foundation (ASF) under one
8  * or more contributor license agreements.  See the NOTICE file
9  * distributed with this work for additional information
10  * regarding copyright ownership.  The ASF licenses this file
11  * to you under the Apache License, Version 2.0 (the
12  * "License"); you may not use this file except in compliance
13  * with the License.  You may obtain a copy of the License at
14  *
15  *   http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing,
18  * software distributed under the License is distributed on an
19  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20  * KIND, either express or implied.  See the License for the
21  * specific language governing permissions and limitations
22  * under the License.
23  * ====================================================================
24  *
25  * This software consists of voluntary contributions made by many
26  * individuals on behalf of the Apache Software Foundation.  For more
27  * information on the Apache Software Foundation, please see
28  * <http://www.apache.org/>.
29  *
30  */
31 
32 package org.apache.http.conn;
33 
34 import java.io.IOException;
35 import java.net.Socket;
36 
37 import org.apache.http.HttpClientConnection;
38 import org.apache.http.HttpHost;
39 import org.apache.http.HttpInetConnection;
40 import org.apache.http.params.HttpParams;
41 
42 
43 /**
44  * A client-side connection that relies on outside logic to connect sockets to the
45  * appropriate hosts. It can be operated directly by an application, or through an
46  * {@link ClientConnectionOperator operator}.
47  *
48  *
49  * @author <a href="mailto:rolandw at apache.org">Roland Weber</a>
50  *
51  *
52  * <!-- empty lines to avoid svn diff problems -->
53  * @version   $Revision: 646087 $ $Date: 2008-04-08 14:36:46 -0700 (Tue, 08 Apr 2008) $
54  *
55  * @since 4.0
56  *
57  * @deprecated Please use {@link java.net.URL#openConnection} instead.
58  *     Please visit <a href="http://android-developers.blogspot.com/2011/09/androids-http-clients.html">this webpage</a>
59  *     for further details.
60  */
61 @Deprecated
62 public interface OperatedClientConnection
63     extends HttpClientConnection, HttpInetConnection {
64 
65     /**
66      * Obtains the target host for this connection.
67      * If the connection is to a proxy but not tunnelled, this is
68      * the proxy. If the connection is tunnelled through a proxy,
69      * this is the target of the tunnel.
70      * <br/>
71      * The return value is well-defined only while the connection is open.
72      * It may change even while the connection is open,
73      * because of an {@link #update update}.
74      *
75      * @return  the host to which this connection is opened
76      */
getTargetHost()77     HttpHost getTargetHost()
78         ;
79 
80     /**
81      * Indicates whether this connection is secure.
82      * The return value is well-defined only while the connection is open.
83      * It may change even while the connection is open,
84      * because of an {@link #update update}.
85      *
86      * @return  <code>true</code> if this connection is secure,
87      *          <code>false</code> otherwise
88      */
isSecure()89     boolean isSecure()
90         ;
91 
92     /**
93      * Obtains the socket for this connection.
94      * The return value is well-defined only while the connection is open.
95      * It may change even while the connection is open,
96      * because of an {@link #update update}.
97      *
98      * @return  the socket for communicating with the
99      *          {@link #getTargetHost target host}
100      */
getSocket()101     Socket getSocket()
102         ;
103 
104 
105     // There is no getParams(). For the moment, we
106     // do not require connections to store parameters.
107 
108 
109     /**
110      * Signals that this connection is in the process of being open.
111      * <br/>
112      * By calling this method, you can provide the connection with
113      * the unconnected socket that will be connected before
114      * {@link #openCompleted} is called. This allows
115      * the connection to close that socket if
116      * {@link org.apache.http.HttpConnection#shutdown shutdown}
117      * is called before it is open. Closing the unconnected socket
118      * will interrupt a thread that is blocked on the connect.
119      * Otherwise, that thread will either time out on the connect,
120      * or it returns successfully and then opens this connection
121      * which was just shut down.
122      * <br/>
123      * You also must call {@link #openCompleted} in order to complete
124      * the process
125      *
126      * @param sock      the unconnected socket which is about to
127      *                  be connected.
128      * @param target    the target host of this connection
129      */
opening(Socket sock, HttpHost target)130     void opening(Socket sock, HttpHost target)
131         throws IOException
132         ;
133 
134 
135     /**
136      * Signals that the connection has been successfully open.
137      * An attempt to call this method on an open connection will cause
138      * an exception.
139      *
140      * @param secure    <code>true</code> if this connection is secure, for
141      *                  example if an <code>SSLSocket</code> is used, or
142      *                  <code>false</code> if it is not secure
143      * @param params    parameters for this connection. The parameters will
144      *                  be used when creating dependent objects, for example
145      *                  to determine buffer sizes.
146      */
openCompleted(boolean secure, HttpParams params)147     void openCompleted(boolean secure, HttpParams params)
148         throws IOException
149         ;
150 
151 
152     /**
153      * Updates this connection.
154      * A connection can be updated only while it is open.
155      * Updates are used for example when a tunnel has been established,
156      * or when a TLS/SSL connection has been layered on top of a plain
157      * socket connection.
158      * <br/>
159      * <b>Note:</b> Updating the connection will <i>not</i> close the
160      * previously used socket. It is the caller's responsibility to close
161      * that socket if it is no longer required.
162      *
163      * @param sock      the new socket for communicating with the target host,
164      *                  or <code>null</code> to continue using the old socket.
165      *                  If <code>null</code> is passed, helper objects that
166      *                  depend on the socket should be re-used. In that case,
167      *                  some changes in the parameters will not take effect.
168      * @param target    the new target host of this connection
169      * @param secure    <code>true</code> if this connection is now secure,
170      *                  <code>false</code> if it is not secure
171      * @param params    new parameters for this connection
172      */
update(Socket sock, HttpHost target, boolean secure, HttpParams params)173     void update(Socket sock, HttpHost target,
174                 boolean secure, HttpParams params)
175         throws IOException
176         ;
177 
178 
179 } // interface OperatedClientConnection
180