Hello.
I may be doing something wrong (wouldn't be the first time!) but I
noticed that my proxy information can get lost during certain types of
page loads. For example, I was trying to load a page when I saw this
exception:
No route to host: connect
java.net.NoRouteToHostException: No route to host: connect
[snip]
at
com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConne
ction.java:125)
at
com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection
(WebClient.java:1354)
at
com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1
321)
at
com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection
(WebClient.java:1387)
at
com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1
321)
at
com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:331)
at
com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:384)
[snip]
I took a look at the code and found this:
WebClient.java (lines 1386 - 1390)
private WebResponse loadWebResponseFromWebConnection(final
WebRequestSettings webRequestSettings) {
[snip]
else if( statusCode =3D=3D 302 || statusCode =3D=3D 303 ) {
final WebRequestSettings wrs =3D new
WebRequestSettings(newUrl);
return loadWebResponse(wrs);
}
[snip]
}
This suggested to me that the subsquent loadWebResponse was not going to
have my proxy info, so I tried this hack:
else if( statusCode =3D=3D 302 || statusCode =3D=3D 303 ) {
webRequestSettings.setURL(newUrl);
return loadWebResponse(webRequestSettings);
}
And it seems to have worked. Unfortunately, this doesn't seem to be the
only at-risk section of the code, for if I enable javascript (the page I
was loading has a javascript page redirect):
May 19, 2006 2:53:20 PM com.gargoylesoftware.htmlunit.html.HtmlPage
loadJavaScriptFromUrl
SEVERE: Error loading javascript from
[http://example.com/somedir/dtree.js]:=20
java.net.NoRouteToHostException: No route to host: connect
Which seems to be due to:
HtmlPage.java (lines 807 - 812)
private String loadJavaScriptFromUrl(final URL url, final String charset
) {
String scriptEncoding =3D charset;
getPageEncoding();
try {
final WebRequestSettings requestSettings =3D new
WebRequestSettings(url);
final WebResponse webResponse =3D
getWebClient().loadWebResponse(requestSettings);
Is this a bug, or just my foolishness?
Thanks,
Ben
|