Tuesday, March 18, 2008

Apache HTTP Client and proxy settings

I don't how many times I've had to do it (and how many times I've screwed it up), but I can never remember just how to set up proxies for Apache HTTP Client. So, to keep a record of my googling and experimenting, here's the entries that really helped:
  • jGuru - just the last thread comment (Vivek Singh - Aug 16, 2007). Check this out if you need to set authentication parameters, as well.

Essentially here's what I ended up with (if you just need proxy name and port):

HttpClient client = new HttpClient();
client.getHostConfiguration().setProxy(proxyHost, port);