1

I can send a Http GET request by InetAddress like above.

HttpParams params = new BasicHttpParams();
params.setParameter(ConnRoutePNames.LOCAL_ADDRESS, InetAddress.getByName(interfaceIp));
HttpClient httpClient = new DefaultHttpClient(params);  
HttpGet httpGet = new HttpGet(baseUrl);
response = httpClient.execute(httpGet);

But I want to try it via HtmlUnit. Is there a way for that?

Edit:

I try this:

WebClient webClient = new WebClient();
HtmlPage page = webClient.getPage(baseurl);
page.getTitleText();
Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
stephan
  • 271
  • 1
  • 4
  • 24

1 Answers1

1

You can use:

InetAddress inetAddress = InetAddress.getByName(interfaceIp);
webClient.getOptions().setLocalAddress(inetAddress);
Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56