From a716e4bbc0b79184de51883ec4b70e994436f9ab Mon Sep 17 00:00:00 2001 From: daniel oeh Date: Sun, 15 Sep 2013 13:16:26 +0200 Subject: [PATCH] Added timeout to GpodnetService --- .../danoeh/antennapod/gpoddernet/GpodnetService.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/de/danoeh/antennapod/gpoddernet/GpodnetService.java b/src/de/danoeh/antennapod/gpoddernet/GpodnetService.java index 7e0a34e0b..be95e5d1b 100644 --- a/src/de/danoeh/antennapod/gpoddernet/GpodnetService.java +++ b/src/de/danoeh/antennapod/gpoddernet/GpodnetService.java @@ -16,6 +16,8 @@ import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.entity.StringEntity; import org.apache.http.impl.auth.BasicScheme; import org.apache.http.params.CoreProtocolPNames; +import org.apache.http.params.HttpConnectionParams; +import org.apache.http.params.HttpParams; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -39,11 +41,16 @@ public class GpodnetService { private static final String BASE_SCHEME = "https"; private static final String BASE_HOST = "gpodder.net"; - private GpodnetClient httpClient; + private static final int TIMEOUT_MILLIS = 20000; + + private final GpodnetClient httpClient; public GpodnetService() { httpClient = new GpodnetClient(); - httpClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT, AppConfig.USER_AGENT); + final HttpParams params = httpClient.getParams(); + params.setParameter(CoreProtocolPNames.USER_AGENT, AppConfig.USER_AGENT); + HttpConnectionParams.setConnectionTimeout(params, TIMEOUT_MILLIS); + HttpConnectionParams.setSoTimeout(params, TIMEOUT_MILLIS); } /**