Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 /**
  * 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;
 }
Esempio n. 3
0
 // 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);
 }
Esempio n. 4
0
 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);
   }
 }
Esempio n. 5
0
 /**
  * Should we use sessionid's?
  *
  * @param tf
  */
 public HTTPSession setUseSessions(boolean tf) {
   localsettings.setParameter(Prop.USESESSIONS, (Boolean) tf);
   this.cachevalid = false;
   return this;
 }
Esempio n. 6
0
 /** Enable/disable redirection following Default is yes. */
 public HTTPSession setFollowRedirects(boolean tf) {
   localsettings.setParameter(Prop.HANDLE_REDIRECTS, (Boolean) tf);
   this.cachevalid = false;
   return this;
 }
Esempio n. 7
0
 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;
 }
Esempio n. 8
0
 /**
  * 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);
 }
Esempio n. 9
0
 /** Enable/disable redirection following Default is yes. */
 public static synchronized void setGlobalFollowRedirects(boolean tf) {
   globalsettings.setParameter(Prop.HANDLE_REDIRECTS, (Boolean) tf);
 }
Esempio n. 10
0
 public static synchronized void setGlobalSoTimeout(int timeout) {
   if (timeout >= 0) globalsettings.setParameter(Prop.SO_TIMEOUT, (Integer) timeout);
 }
Esempio n. 11
0
 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);
   }
 }
Esempio n. 12
0
 public static synchronized void setGlobalUserAgent(String userAgent) {
   globalsettings.setParameter(Prop.USER_AGENT, userAgent);
 }