summaryrefslogtreecommitdiffstats
path: root/core/java/android/net/http
diff options
context:
space:
mode:
authorHenrik Baard <henrik.baard@sonyericsson.com>2010-11-18 14:08:36 +0100
committerHenrik Baard <henrik.baard@sonyericsson.com>2010-12-06 07:57:02 +0100
commitd39fd5a97c6f56794a6ed7ac1dfb0bbf585becf1 (patch)
treec0e1abe4b18cd364d73c9fff1537e598e971bb84 /core/java/android/net/http
parentbf1439c513f0d24a9d23755b50750831574785f4 (diff)
downloadframeworks_base-d39fd5a97c6f56794a6ed7ac1dfb0bbf585becf1.zip
frameworks_base-d39fd5a97c6f56794a6ed7ac1dfb0bbf585becf1.tar.gz
frameworks_base-d39fd5a97c6f56794a6ed7ac1dfb0bbf585becf1.tar.bz2
Changing connect and response timeout.
In bad network conditions and where switches often occur between 2G and 3G the timeout of 20s is too short. Setting this timeout to 60 seconds will improve functionality in bad conditions while it will not affect functionality in good networks. This change also aligns the timeouts with the timeouts used by the Browser (Connection.java). Change-Id: I0fbe3cbfe734f8d55a41bfa5d8ab6b332a19f912
Diffstat (limited to 'core/java/android/net/http')
-rw-r--r--core/java/android/net/http/AndroidHttpClient.java11
1 files changed, 7 insertions, 4 deletions
diff --git a/core/java/android/net/http/AndroidHttpClient.java b/core/java/android/net/http/AndroidHttpClient.java
index e07ee59..8dc2a86 100644
--- a/core/java/android/net/http/AndroidHttpClient.java
+++ b/core/java/android/net/http/AndroidHttpClient.java
@@ -79,6 +79,9 @@ public final class AndroidHttpClient implements HttpClient {
// Gzip of data shorter than this probably won't be worthwhile
public static long DEFAULT_SYNC_MIN_GZIP_BYTES = 256;
+ // Default connection and socket timeout of 60 seconds. Tweak to taste.
+ private static final int SOCKET_OPERATION_TIMEOUT = 60 * 1000;
+
private static final String TAG = "AndroidHttpClient";
@@ -107,9 +110,8 @@ public final class AndroidHttpClient implements HttpClient {
// and it's not worth it to pay the penalty of checking every time.
HttpConnectionParams.setStaleCheckingEnabled(params, false);
- // Default connection and socket timeout of 20 seconds. Tweak to taste.
- HttpConnectionParams.setConnectionTimeout(params, 20 * 1000);
- HttpConnectionParams.setSoTimeout(params, 20 * 1000);
+ HttpConnectionParams.setConnectionTimeout(params, SOCKET_OPERATION_TIMEOUT);
+ HttpConnectionParams.setSoTimeout(params, SOCKET_OPERATION_TIMEOUT);
HttpConnectionParams.setSocketBufferSize(params, 8192);
// Don't handle redirects -- return them to the caller. Our code
@@ -125,7 +127,8 @@ public final class AndroidHttpClient implements HttpClient {
schemeRegistry.register(new Scheme("http",
PlainSocketFactory.getSocketFactory(), 80));
schemeRegistry.register(new Scheme("https",
- SSLCertificateSocketFactory.getHttpSocketFactory(30 * 1000, sessionCache), 443));
+ SSLCertificateSocketFactory.getHttpSocketFactory(
+ SOCKET_OPERATION_TIMEOUT, sessionCache), 443));
ClientConnectionManager manager =
new ThreadSafeClientConnManager(params, schemeRegistry);