Example #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;
 }
Example #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;
 }
Example #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);
 }
Example #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);
   }
 }
Example #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;
 }
Example #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;
 }
Example #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;
 }
Example #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);
 }
Example #9
0
 /** Enable/disable redirection following Default is yes. */
 public static synchronized void setGlobalFollowRedirects(boolean tf) {
   globalsettings.setParameter(Prop.HANDLE_REDIRECTS, (Boolean) tf);
 }
Example #10
0
 public static synchronized void setGlobalSoTimeout(int timeout) {
   if (timeout >= 0) globalsettings.setParameter(Prop.SO_TIMEOUT, (Integer) timeout);
 }
Example #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);
   }
 }
Example #12
0
 public static synchronized void setGlobalUserAgent(String userAgent) {
   globalsettings.setParameter(Prop.USER_AGENT, userAgent);
 }