Code:
public class HTTPTest {public static void main(String[] args) {
try {
Properties prop = new Properties(System.getProperties());
prop.put("http.proxySet", "true");
prop.put("http.proxyHost", "138.33.1.81");
prop.put("http.proxyPort", "8080");
prop.put("https.proxyHost", "138.33.1.81");
prop.put("https.proxyPort", "8080");
Properties newprops = new Properties(prop);
System.setProperties(newprops);
String path = "http://www.google.de/";
URL url = new URL(path);
HttpURLConnection httpURLConnection = (HttpURLConnection) url
.openConnection();
InputStream inputStream = httpURLConnection.getInputStream();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
int len = 0;
byte[] BUFFER = new byte[4096];
while ((len = inputStream.read(BUFFER)) != -1) {
outputStream.write(BUFFER, 0, len);
}
inputStream.close();
outputStream.close();
System.out.println(outputStream.size());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}}
Diese Fehlermeldung kommt, wenn ich ne Connection aufbauen will.
Server returned HTTP response code: 407
=> ich soll Benutzername und Passwort mitgeben.
Mein Abeitskollege braucht nichts mitgeben bei glechem Quellcode.
Hat er andere Rechte wenn er auf den Proxy zugreift?[/code]