Exemplo n.º 1
0
 public static synchronized void setGlobalProxy(String proxyurl) {
   if (proxyurl == null) throw new IllegalArgumentException("Bad proxy URL: " + proxyurl);
   URI uri;
   try {
     uri = HTTPUtil.parseToURI(proxyurl);
   } catch (URISyntaxException e) {
     throw new IllegalArgumentException("Bad proxy URL: " + proxyurl);
   }
   if (uri.getScheme().equals("http"))
     httpproxy = new HttpHost(uri.getHost(), uri.getPort(), "http");
   else if (uri.getScheme().equals("https"))
     httpsproxy = new HttpHost(uri.getHost(), uri.getPort(), "https");
   String upw = uri.getUserInfo();
   if (upw != null) {
     String[] pieces = upw.split("[:]");
     if (pieces.length != 2
         || HTTPUtil.nullify(pieces[0]) == null
         || HTTPUtil.nullify(pieces[1]) == null)
       throw new IllegalArgumentException("Bad userinfo: " + proxyurl);
     proxyuser = pieces[0];
     proxypwd = pieces[1];
   }
 }
Exemplo n.º 2
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);
   }
 }