Added timeout settings to the URLConnection
This commit is contained in:
@@ -31,6 +31,7 @@ import com.moviejukebox.themoviedb.model.Person;
|
||||
import com.moviejukebox.themoviedb.tools.DOMHelper;
|
||||
import com.moviejukebox.themoviedb.tools.DOMParser;
|
||||
import com.moviejukebox.themoviedb.tools.LogFormatter;
|
||||
import com.moviejukebox.themoviedb.tools.WebBrowser;
|
||||
|
||||
/**
|
||||
* This is the main class for the API to connect to TheMovieDb.org The implementation is for v2.1
|
||||
@@ -58,6 +59,18 @@ public class TheMovieDb {
|
||||
setApiKey(apiKey);
|
||||
}
|
||||
|
||||
public void setProxy(String host, String port, String username, String password) {
|
||||
WebBrowser.setProxyHost(host);
|
||||
WebBrowser.setProxyPort(port);
|
||||
WebBrowser.setProxyUsername(username);
|
||||
WebBrowser.setProxyPassword(password);
|
||||
}
|
||||
|
||||
public void setTimeout(int webTimeoutConnect, int webTimeoutRead) {
|
||||
WebBrowser.setWebTimeoutConnect(webTimeoutConnect);
|
||||
WebBrowser.setWebTimeoutRead(webTimeoutRead);
|
||||
}
|
||||
|
||||
public static Logger getLogger() {
|
||||
return logger;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import java.util.regex.Pattern;
|
||||
* Web browser with simple cookies support
|
||||
*/
|
||||
public final class WebBrowser {
|
||||
|
||||
private static Map<String, String> browserProperties = new HashMap<String, String>();
|
||||
private static Map<String, Map<String, String>> cookies;
|
||||
private static String proxyHost = null;
|
||||
@@ -39,6 +40,8 @@ public final class WebBrowser {
|
||||
private static String proxyUsername = null;
|
||||
private static String proxyPassword = null;
|
||||
private static String proxyEncodedPassword = null;
|
||||
private static int webTimeoutConnect = 10000; // 10 second timeout
|
||||
private static int webTimeoutRead = 90000; // 90 second timeout
|
||||
|
||||
static {
|
||||
browserProperties.put("User-Agent", "Mozilla/5.25 Netscape/5.0 (Windows; I; Win95)");
|
||||
@@ -234,4 +237,20 @@ public final class WebBrowser {
|
||||
proxyEncodedPassword = Base64.base64Encode(proxyEncodedPassword);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getWebTimeoutConnect() {
|
||||
return webTimeoutConnect;
|
||||
}
|
||||
|
||||
public static int getWebTimeoutRead() {
|
||||
return webTimeoutRead;
|
||||
}
|
||||
|
||||
public static void setWebTimeoutConnect(int webTimeoutConnect) {
|
||||
WebBrowser.webTimeoutConnect = webTimeoutConnect;
|
||||
}
|
||||
|
||||
public static void setWebTimeoutRead(int webTimeoutRead) {
|
||||
WebBrowser.webTimeoutRead = webTimeoutRead;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user