From: ChrisMBX <chr...@gm...> - 2014-02-12 13:45:31
|
Hi all, I cannot access http pages through a proxy with WebClient. When I use an URLConnection there is no problem : Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("hostname", 8080)); URLConnection urlConnection = new URL("https://www.google.com/").openConnection(proxy); BufferedReader bufferedReader = null; try { bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); String line; while ((line = bufferedReader.readLine()) != null) { System.out.println(line); } } finally { if (bufferedReader != null) { bufferedReader.close(); } } But when I try with WebClient, I have an error : WebClient webClient = new WebClient(BrowserVersion.CHROME, "hostname", 8080); webClient.getOptions().setThrowExceptionOnFailingStatusCode(false); webClient.getOptions().setThrowExceptionOnScriptError(false); HtmlPage htmlPage = webClient.getPage("https://www.google.com/"); System.out.println(htmlPage.asText()); The error is "407 Proxy Authentication Required. The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied." I don't understand why with URLConnection there is no authentification problem. Thank you for your help ! -- View this message in context: http://htmlunit.10904.n7.nabble.com/Proxy-problem-OK-with-URLConnection-KO-with-WebClient-tp33167.html Sent from the HtmlUnit - General mailing list archive at Nabble.com. |