protected RequestConfig configureRequest(RequestConfig.Builder rcb, Settings settings) throws HTTPException { // Configure the RequestConfig for (Prop key : settings.getKeys()) { Object value = settings.getParameter(key); boolean tf = (value instanceof Boolean ? (Boolean) value : false); if (key == Prop.ALLOW_CIRCULAR_REDIRECTS) { rcb.setCircularRedirectsAllowed(tf); } else if (key == Prop.HANDLE_REDIRECTS) { rcb.setRedirectsEnabled(tf); rcb.setRelativeRedirectsAllowed(tf); } else if (key == Prop.MAX_REDIRECTS) { rcb.setMaxRedirects((Integer) value); } else if (key == Prop.SO_TIMEOUT) { rcb.setSocketTimeout((Integer) value); } else if (key == Prop.CONN_TIMEOUT) { rcb.setConnectTimeout((Integer) value); } else if (key == Prop.CONN_REQ_TIMEOUT) { rcb.setConnectionRequestTimeout((Integer) value); } else if (key == Prop.MAX_THREADS) { connmgr.setMaxTotal((Integer) value); connmgr.setDefaultMaxPerRoute((Integer) value); } /* else ignore */ } RequestConfig cfg = rcb.build(); return cfg; }
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); } }
public static synchronized String getGlobalUserAgent() { return (String) globalsettings.getParameter(Prop.USER_AGENT); }