1069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project/*
2069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpConnectionParams.java $
3069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * $Revision: 576089 $
4069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * $Date: 2007-09-16 05:39:56 -0700 (Sun, 16 Sep 2007) $
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.params;
33069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
34069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project/**
35069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * An adaptor for accessing connection parameters in {@link HttpParams}.
36069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * <br/>
37069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * Note that the <i>implements</i> relation to {@link CoreConnectionPNames}
38069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * is for compatibility with existing application code only. References to
39069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * the parameter names should use the interface, not this class.
40069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project *
41069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
42069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project *
43069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * @version $Revision: 576089 $
44069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project *
45069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * @since 4.0
46d42abb2fd917184764daf22f5f299e848b8701d7Narayan Kamath *
47d42abb2fd917184764daf22f5f299e848b8701d7Narayan Kamath * @deprecated Please use {@link java.net.URL#openConnection} instead.
48d42abb2fd917184764daf22f5f299e848b8701d7Narayan Kamath *     Please visit <a href="http://android-developers.blogspot.com/2011/09/androids-http-clients.html">this webpage</a>
49d42abb2fd917184764daf22f5f299e848b8701d7Narayan Kamath *     for further details.
50069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project */
51d42abb2fd917184764daf22f5f299e848b8701d7Narayan Kamath@Deprecated
52069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Projectpublic final class HttpConnectionParams implements CoreConnectionPNames {
53069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
54069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    /**
55069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     */
56069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    private HttpConnectionParams() {
57069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        super();
58069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    }
59069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
60069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    /**
61069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Returns the default socket timeout (<tt>SO_TIMEOUT</tt>) in milliseconds which is the
62069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * timeout for waiting for data. A timeout value of zero is interpreted as an infinite
63069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * timeout. This value is used when no socket timeout is set in the
64069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * method parameters.
65069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *
66069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @return timeout in milliseconds
67069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     */
68069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    public static int getSoTimeout(final HttpParams params) {
69069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        if (params == null) {
70069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project            throw new IllegalArgumentException("HTTP parameters may not be null");
71069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        }
72069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        return params.getIntParameter(CoreConnectionPNames.SO_TIMEOUT, 0);
73069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    }
74069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
75069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    /**
76069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Sets the default socket timeout (<tt>SO_TIMEOUT</tt>) in milliseconds which is the
77069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * timeout for waiting for data. A timeout value of zero is interpreted as an infinite
78069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * timeout. This value is used when no socket timeout is set in the
79069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * method parameters.
80069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *
81069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @param timeout Timeout in milliseconds
82069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     */
83069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    public static void setSoTimeout(final HttpParams params, int timeout) {
84069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        if (params == null) {
85069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project            throw new IllegalArgumentException("HTTP parameters may not be null");
86069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        }
87069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, timeout);
88069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
89069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    }
90069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
91069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    /**
92069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Tests if Nagle's algorithm is to be used.
93069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *
94069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @return <tt>true</tt> if the Nagle's algorithm is to NOT be used
95069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *   (that is enable TCP_NODELAY), <tt>false</tt> otherwise.
96069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     */
97069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    public static boolean getTcpNoDelay(final HttpParams params) {
98069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        if (params == null) {
99069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project            throw new IllegalArgumentException("HTTP parameters may not be null");
100069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        }
101069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        return params.getBooleanParameter
102069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project            (CoreConnectionPNames.TCP_NODELAY, true);
103069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    }
104069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
105069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    /**
106069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Determines whether Nagle's algorithm is to be used. The Nagle's algorithm
107069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * tries to conserve bandwidth by minimizing the number of segments that are
108069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * sent. When applications wish to decrease network latency and increase
109069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * performance, they can disable Nagle's algorithm (that is enable TCP_NODELAY).
110069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Data will be sent earlier, at the cost of an increase in bandwidth consumption.
111069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *
112069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @param value <tt>true</tt> if the Nagle's algorithm is to NOT be used
113069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *   (that is enable TCP_NODELAY), <tt>false</tt> otherwise.
114069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     */
115069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    public static void setTcpNoDelay(final HttpParams params, boolean value) {
116069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        if (params == null) {
117069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project            throw new IllegalArgumentException("HTTP parameters may not be null");
118069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        }
119069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        params.setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, value);
120069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    }
121069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
122069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    public static int getSocketBufferSize(final HttpParams params) {
123069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        if (params == null) {
124069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project            throw new IllegalArgumentException("HTTP parameters may not be null");
125069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        }
126069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        return params.getIntParameter
127069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project            (CoreConnectionPNames.SOCKET_BUFFER_SIZE, -1);
128069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    }
129069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
130069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    public static void setSocketBufferSize(final HttpParams params, int size) {
131069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        if (params == null) {
132069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project            throw new IllegalArgumentException("HTTP parameters may not be null");
133069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        }
134069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        params.setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, size);
135069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    }
136069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
137069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    /**
138069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Returns linger-on-close timeout. Value <tt>0</tt> implies that the option is
139069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * disabled. Value <tt>-1</tt> implies that the JRE default is used.
140069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *
141069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @return the linger-on-close timeout
142069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     */
143069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    public static int getLinger(final HttpParams params) {
144069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        if (params == null) {
145069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project            throw new IllegalArgumentException("HTTP parameters may not be null");
146069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        }
147069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        return params.getIntParameter(CoreConnectionPNames.SO_LINGER, -1);
148069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    }
149069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
150069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    /**
151069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Returns linger-on-close timeout. This option disables/enables immediate return
152069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * from a close() of a TCP Socket. Enabling this option with a non-zero Integer
153069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * timeout means that a close() will block pending the transmission and
154069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * acknowledgement of all data written to the peer, at which point the socket is
155069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * closed gracefully. Value <tt>0</tt> implies that the option is
156069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * disabled. Value <tt>-1</tt> implies that the JRE default is used.
157069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *
158069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @param value the linger-on-close timeout
159069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     */
160069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    public static void setLinger(final HttpParams params, int value) {
161069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        if (params == null) {
162069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project            throw new IllegalArgumentException("HTTP parameters may not be null");
163069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        }
164069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        params.setIntParameter(CoreConnectionPNames.SO_LINGER, value);
165069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    }
166069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
167069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    /**
168069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Returns the timeout until a connection is etablished. A value of zero
169069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * means the timeout is not used. The default value is zero.
170069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *
171069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @return timeout in milliseconds.
172069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     */
173069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    public static int getConnectionTimeout(final HttpParams params) {
174069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        if (params == null) {
175069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project            throw new IllegalArgumentException("HTTP parameters may not be null");
176069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        }
177069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        return params.getIntParameter
178069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project            (CoreConnectionPNames.CONNECTION_TIMEOUT, 0);
179069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    }
180069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
181069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    /**
182069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Sets the timeout until a connection is etablished. A value of zero
183069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * means the timeout is not used. The default value is zero.
184069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *
185069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @param timeout Timeout in milliseconds.
186069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     */
187069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    public static void setConnectionTimeout(final HttpParams params, int timeout) {
188069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        if (params == null) {
189069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project            throw new IllegalArgumentException("HTTP parameters may not be null");
190069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        }
191069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        params.setIntParameter
192069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project            (CoreConnectionPNames.CONNECTION_TIMEOUT, timeout);
193069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    }
194069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
195069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    /**
196069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Tests whether stale connection check is to be used. Disabling
197069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * stale connection check may result in slight performance improvement
198069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * at the risk of getting an I/O error when executing a request over a
199069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * connection that has been closed at the server side.
200069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *
201069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @return <tt>true</tt> if stale connection check is to be used,
202069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *   <tt>false</tt> otherwise.
203069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     */
204069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    public static boolean isStaleCheckingEnabled(final HttpParams params) {
205069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        if (params == null) {
206069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project            throw new IllegalArgumentException("HTTP parameters may not be null");
207069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        }
208069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        return params.getBooleanParameter
209069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project            (CoreConnectionPNames.STALE_CONNECTION_CHECK, true);
210069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    }
211069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
212069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    /**
213069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Defines whether stale connection check is to be used. Disabling
214069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * stale connection check may result in slight performance improvement
215069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * at the risk of getting an I/O error when executing a request over a
216069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * connection that has been closed at the server side.
217069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *
218069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @param value <tt>true</tt> if stale connection check is to be used,
219069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *   <tt>false</tt> otherwise.
220069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     */
221069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    public static void setStaleCheckingEnabled(final HttpParams params, boolean value) {
222069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        if (params == null) {
223069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project            throw new IllegalArgumentException("HTTP parameters may not be null");
224069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        }
225069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        params.setBooleanParameter
226069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project            (CoreConnectionPNames.STALE_CONNECTION_CHECK, value);
227069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    }
228069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
229069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project}
230