简体   繁体   中英

How to post HEAD request with HtmlUnit?

How can I use existing WebClient to post a custom HEAD request? Ie there is no form on the page, I want to set request properties manually.

Use WebClient#getPage() where you pass the WebRequestSettings in which you can construct with a HttpMethod of HEAD .

Thus, basically:

Page page = webClient.getPage(new WebRequestSettings(new URL("http://stackoverflow.com"), HttpMethod.HEAD));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM