public HTTPSession setConnectionTimeout(int timeout) { if (timeout <= 0) throw new IllegalArgumentException("setConnectionTImeout"); localsettings.setParameter(Prop.CONN_TIMEOUT, timeout); localsettings.setParameter(Prop.CONN_REQ_TIMEOUT, timeout); this.cachevalid = false; return this; }
/** * Set the max number of redirects to follow * * @param n */ public HTTPSession setMaxRedirects(int n) { if (n < 0) // validate throw new IllegalArgumentException("setMaxRedirects"); localsettings.setParameter(Prop.MAX_REDIRECTS, n); this.cachevalid = false; return this; }
// Provide defaults for a settings map protected static void setDefaults(Settings props) { if (false) { // turn off for now props.setParameter(Prop.HANDLE_AUTHENTICATION, Boolean.TRUE); } props.setParameter(Prop.HANDLE_REDIRECTS, Boolean.TRUE); props.setParameter(Prop.ALLOW_CIRCULAR_REDIRECTS, Boolean.TRUE); props.setParameter(Prop.MAX_REDIRECTS, (Integer) DFALTREDIRECTS); props.setParameter(Prop.SO_TIMEOUT, (Integer) DFALTSOTIMEOUT); props.setParameter(Prop.CONN_TIMEOUT, (Integer) DFALTCONNTIMEOUT); props.setParameter(Prop.CONN_REQ_TIMEOUT, (Integer) DFALTCONNREQTIMEOUT); props.setParameter(Prop.USER_AGENT, DFALTUSERAGENT); }
public static synchronized void setGlobalCompression(String compressors) { if (globalsettings.getParameter(Prop.COMPRESSION) != null) removeGlobalCompression(); String compresslist = checkCompressors(compressors); if (HTTPUtil.nullify(compresslist) == null) throw new IllegalArgumentException("Bad compressors: " + compressors); globalsettings.setParameter(Prop.COMPRESSION, compresslist); HttpResponseInterceptor hrsi; if (compresslist.contains("gzip")) { hrsi = new GZIPResponseInterceptor(); rspintercepts.add(hrsi); } if (compresslist.contains("deflate")) { hrsi = new DeflateResponseInterceptor(); rspintercepts.add(hrsi); } }
/** * Should we use sessionid's? * * @param tf */ public HTTPSession setUseSessions(boolean tf) { localsettings.setParameter(Prop.USESESSIONS, (Boolean) tf); this.cachevalid = false; return this; }
/** Enable/disable redirection following Default is yes. */ public HTTPSession setFollowRedirects(boolean tf) { localsettings.setParameter(Prop.HANDLE_REDIRECTS, (Boolean) tf); this.cachevalid = false; return this; }
public HTTPSession setUserAgent(String agent) { if (agent == null || agent.length() == 0) throw new IllegalArgumentException("null argument"); localsettings.setParameter(Prop.USER_AGENT, agent); this.cachevalid = false; return this; }
/** * Set the max number of redirects to follow * * @param n */ public static synchronized void setGlobalMaxRedirects(int n) { if (n < 0) // validate throw new IllegalArgumentException("setMaxRedirects"); globalsettings.setParameter(Prop.MAX_REDIRECTS, n); }
/** Enable/disable redirection following Default is yes. */ public static synchronized void setGlobalFollowRedirects(boolean tf) { globalsettings.setParameter(Prop.HANDLE_REDIRECTS, (Boolean) tf); }
public static synchronized void setGlobalSoTimeout(int timeout) { if (timeout >= 0) globalsettings.setParameter(Prop.SO_TIMEOUT, (Integer) timeout); }
public static synchronized void setGlobalConnectionTimeout(int timeout) { if (timeout >= 0) { globalsettings.setParameter(Prop.CONN_TIMEOUT, (Integer) timeout); globalsettings.setParameter(Prop.CONN_REQ_TIMEOUT, (Integer) timeout); } }
public static synchronized void setGlobalUserAgent(String userAgent) { globalsettings.setParameter(Prop.USER_AGENT, userAgent); }