R
Robert M. Gary
I have been fighting with proxy issues for some time and finally solved
it. Originally I was doing the following...
String url = "http://www.goodhost.com:80",
proxy = "64.202.165.130",
port = "3128";
URL server = new URL(url);
System.getProperties().put("http.proxySet","true");
System.getProperties().put("http.proxyHost",proxy);
System.getProperties().put("http.proxyPort",port);
HttpURLConnection conn = (
HttpURLConnection)server.openConnection();
conn.connect();
But the proxy was never used. I always got a security exception on
"www.goodhost.com" and changing the proxy to be invalid did not cause
any error. So I went down to the http level and it worked....
URL server = new URL(url);
Socket socket = new Socket(proxy,port);
Writer writer = new OutputStreamWriter(socket.getOutputStream(),
"US-ASCII");
writer.write("GET " + server.toExternalForm() + " HTTP/1.0\r\n");
writer.write("Host: " + server.getHost() + "\r\n\r\n");
So my question, is "Why doesn't the http.proxySet work? Why do I have
to manage the http myself? Im running java 1.5.0_07 in Tomcat. I would
really rather not do the HTTP myself.
-Robert
it. Originally I was doing the following...
String url = "http://www.goodhost.com:80",
proxy = "64.202.165.130",
port = "3128";
URL server = new URL(url);
System.getProperties().put("http.proxySet","true");
System.getProperties().put("http.proxyHost",proxy);
System.getProperties().put("http.proxyPort",port);
HttpURLConnection conn = (
HttpURLConnection)server.openConnection();
conn.connect();
But the proxy was never used. I always got a security exception on
"www.goodhost.com" and changing the proxy to be invalid did not cause
any error. So I went down to the http level and it worked....
URL server = new URL(url);
Socket socket = new Socket(proxy,port);
Writer writer = new OutputStreamWriter(socket.getOutputStream(),
"US-ASCII");
writer.write("GET " + server.toExternalForm() + " HTTP/1.0\r\n");
writer.write("Host: " + server.getHost() + "\r\n\r\n");
So my question, is "Why doesn't the http.proxySet work? Why do I have
to manage the http myself? Im running java 1.5.0_07 in Tomcat. I would
really rather not do the HTTP myself.
-Robert