HTMLUNIT中的错误代理自动配置

时间:2013-11-20 10:36:12

标签: java proxy htmlunit pac

我有一个使用Htmlunit的应用程序,我需要使用PAC文件,但HtmlUnit显示错误,我不知道为什么。

PAC文件是用Javascript编写的,扩展名为“.cgi”。

代码是:

WebClient webClient = new WebClient();

webClient.getOptions().setJavaScriptEnabled(true); webClient.getOptions().setActiveXNative(true); webClient.getOptions().setAppletEnabled(true); webClient.getOptions().setCssEnabled(false); webClient.getOptions().setPopupBlockerEnabled(true); webClient.getOptions().setRedirectEnabled(true); webClient.getOptions().setThrowExceptionOnFailingStatusCode(false); webClient.getOptions().setThrowExceptionOnScriptError(false); webClient.getOptions().setUseInsecureSSL(true);

webClient.setAjaxController(new NicelyResynchronizingAjaxController());

webClient.getOptions().getProxyConfig().setProxyAutoConfigUrl("http://domain/proxy.pac");

HtmlPage currentPage = webClient.getPage(web);

错误是:

Exception in thread "main" java.lang.StackOverflowError at java.io.IOException.<init>(IOException.java:58) at java.io.InterruptedIOException.<init>(InterruptedIOException.java:64) at java.net.SocketTimeoutException.<init>(SocketTimeoutException.java:43) at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:150) at java.net.SocketInputStream.read(SocketInputStream.java:121) at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:160) at org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:84) at org.apache.http.impl.io.SocketInputBuffer.isDataAvailable(SocketInputBuffer.java:95) at org.apache.http.impl.AbstractHttpClientConnection.isStale(AbstractHttpClientConnection.java:310) at org.apache.http.impl.conn.ManagedClientConnectionImpl.isStale(ManagedClientConnectionImpl.java:158) at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:432) at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72) at com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:167) at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1281) at com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1198) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:307) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:376) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:361) at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1237) at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1339) at com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1198) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:307) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:376) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:361)

还有更多的错误,但我没有推杆。

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

webClient.getOptions().getProxyConfig().setProxyAutoConfigUrl("http://domain/proxy.pac");   

我认为上面的问题请检查代理网址这是不正确的。 如果打开正确,请先在浏览器中打开然后将其应用于代码。