oneat
oneat

Reputation: 10994

HTMLUnit how to check if proxy is working properly

Do you know what can I do to check if proxy in WebBrowser is working properly?

Upvotes: 0

Views: 911

Answers (1)

Ahmed Ashour
Ahmed Ashour

Reputation: 5559

  1. Well, if the proxy does not exist, you will have an error:

    WebClient webClient = new WebClient(BrowserVersion.INTERNET_EXPLORER_8, "localhost", 8080);
    HtmlPage page = webClient.getPage("http://htmlunit.sf.net");
    System.out.println(page.asText());
    
org.apache.http.conn.HttpHostConnectException:

Connection to http://localhost:8080 refused at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:127) at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:147)

  1. If the proxy misbehaves, you will have a different page than what you expected

Upvotes: 1

Related Questions