HttpsURLConnection wi proxy +How to use HttpsURLConnection through proxy by setProperty? URL connection and proxy : HttpURLConnection
ReportQuestion
Example 1
Properties systemSettings = System.getProperties();
systemSettings.put("proxySet", "true");
systemSettings.put("http.proxyHost", "proxy.my_company.local");
systemSettings.put("http.proxyPort", "80");
URL url = new URL("http://www.xxxxx.com");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
sun.misc.BASE64Encoder encoder = new sun.misc.BASE64Encoder();
String encodedUserPwd = encoder.encode("domain\username:password".getBytes());
con.setRequestProperty("Proxy-Authorization", "Basic " + encodedUserPwd);
con.setRequestMethod("HEAD");
System.out.println(con.getResponseCode() + " : " + con.getResponseMessage());
System.out.println(con.getResponseCode() == HttpURLConnection.HTTP_OK);
————————————————————————————————–
The Networking Properties
You have to set ...
Please briefly explain why you feel this question should be reported .
0
Java
11 months
0 Answers
10 views