G'day, I am trying to set a URLConnection property for proxy authentication. Here's a simple test I've created:
import java.net.*;
public class ProxyTest {
public static void main(String[] args) {
try {
System.setProperty("http.proxyHost", "192.168.107.24");
System.setProperty("http.proxyPort", "3128");
URL url=new URL("http://google.com");
URLConnection uc = url.openConnection ();
uc.setRequestProperty( "Proxy-Authorization", "foobar");
System.out.println("Proxy-Authorization is: " + uc.getRequestProperty("Proxy-Authorization"));
uc.connect();
} catch (Exception e) {
e.printStackTrace();
}
}
}
This always gives my "Proxy-Authorization is null". I have tested this on java 1.6 and 1.5, on a linux system and a windows xp system. In my real app the url connection always gives me 407 unauthorized, I have used tcpdump to check just in case the Proxy-Authorization is being sent, but it isn't.
I am probably missing something simple - can anyone see what it might be? Cheers.