Increased socket and connection timeout of HTTP downloader

This commit is contained in:
daniel oeh 2013-01-13 22:58:00 +01:00
parent 1d8107827c
commit 39ac2b1492
1 changed files with 5 additions and 2 deletions

View File

@ -16,6 +16,7 @@ import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.params.HttpClientParams; import org.apache.http.client.params.HttpClientParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams; import org.apache.http.params.HttpParams;
import android.net.http.AndroidHttpClient; import android.net.http.AndroidHttpClient;
@ -33,7 +34,8 @@ public class HttpDownloader extends Downloader {
private static final int MAX_REDIRECTS = 5; private static final int MAX_REDIRECTS = 5;
private static final int BUFFER_SIZE = 8 * 1024; private static final int BUFFER_SIZE = 8 * 1024;
private static final int CONNECTION_TIMEOUT = 5000; private static final int CONNECTION_TIMEOUT = 30000;
private static final int SOCKET_TIMEOUT = 30000;
public HttpDownloader(DownloaderCallback downloaderCallback, public HttpDownloader(DownloaderCallback downloaderCallback,
DownloadStatus status) { DownloadStatus status) {
@ -46,7 +48,8 @@ public class HttpDownloader extends Downloader {
params.setIntParameter("http.protocol.max-redirects", MAX_REDIRECTS); params.setIntParameter("http.protocol.max-redirects", MAX_REDIRECTS);
params.setBooleanParameter("http.protocol.reject-relative-redirect", params.setBooleanParameter("http.protocol.reject-relative-redirect",
false); false);
params.setIntParameter("http.socket.timeout", CONNECTION_TIMEOUT); HttpConnectionParams.setSoTimeout(params, SOCKET_TIMEOUT);
HttpConnectionParams.setConnectionTimeout(params, CONNECTION_TIMEOUT);
HttpClientParams.setRedirecting(params, true); HttpClientParams.setRedirecting(params, true);
return httpClient; return httpClient;
} }