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]; } }