I'm trying to use the latest (4.0.1) Apache http core components library. However, my web browser goes through a proxy - suppose it is myproxy.com:9191. Could someone provide some sample code for getting a simple http get to use this as a proxy?
I've tried adding the following at the beginning of my code, but had no joy:
ProxySelector.setDefault(new ProxySelector() {
public List<Proxy> select(URI uri) {
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("myproxy.com", 9191);
return Arrays.asList(new Proxy[]{proxy)});
}
public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
ioe.printStackTrace();
}
});